Hey guys, I want to be able to pass an array ID through a URL.
So that it looks like this
array.php?ID=2 and whatever 3 is in the array, gets displayed. Here is the code Im using for that:
<?php
$test = array(1=>"thing1", 2=>"thing2");
$array_count = count($test);
$testvalue=$_GET['id'];
echo $test[$testvalue];
?>
Now, normally that works as you'll actually be linking right to array.php?ID=2 so it actually echos "thing2". However, if you just load up array.php without the ?id=, it produces the following error:
Notice: Undefined index: test in array.php on line 4
Notice: Undefined index: in array.php on line 5
This isnt a problem if you're just linking to it, but I need to include this file in another file to gain access to the $array_count variable. When I do, those notices appear, and that's not good.
Is there a BETTER way of making it so you can use ?id= in a URL such that those notices dont appear? Or do I have to disable notices in the php.ini file on my server?
Thanks in advance for the help 😃