Welcome to WebmasterWorld Guest from 126.96.36.199
Notice: Undefined offset: 0 in C:\Program Files\Apache Group\Apache2\htdocs\miterbox3\test.php on line 15
I hate to admit it, but I have no idea what this means.
I found this on php.net...
$a = "1"; // $a is a string
$a = "f"; // What about string offsets? What happens?
Since PHP (for historical reasons) supports indexing into strings via offsets using the same syntax as array indexing, the example above leads to a problem: should $a become an array with its first element being "f", or should "f" become the first character of the string $a?
The current versions of PHP interpret the second assignment as a string offset identification, so $a becomes "f", the result of this automatic conversion however should be considered undefined.
...but it doesn't help me much. If it's misinterpretting "$href = $hrefs[$i]["link"];", how can I make it understand that I'm trying to reference a certain item in the $hrefs array?
Thanks alot for your help and understanding.
11 $hrefs = array("one" => array("id"=> "","link" => "test.php?id=one"),
12 "two" => array("id"=>"","link"=>"test.php?id=two"),
13 "three" => array("id" => "", "link" => "test.php?id=three"));
$hrefs = array();
$hrefs = array("id"=> "","link" => "test.php?id=one");
$hrefs = array("id"=>"","link"=>"test.php?id=two");
$hrefs = array("id" => "", "link" => "test.php?id=three");
* saying that the offset is undefined is basically saying that in the array you mention, for that particular 'key' of the array (the part in the  or ...) it hasn't been set - there's no value for that key, just like you have unset variables.
* php is pretty smart when flipping around data types when it comes to ints, strings, floats, etc., but it's not smart enough with the string 'one' to go searching for
$array['one']when you create an int in your
forloop. It'll be looking for
$array. If you've got an
$array['1'], this would probably do the trick (not sure - php is dynamically typed, but I'm not sure how this behavior goes with arrays).
* also remember that most things in php begin with 0. You're beginning with 'one'.
* What the code that I posted does is makes
$hrefsan array; then it adds to this array those values you see with
$hrefs =. If you use empty brackets, php automatically indexes your array for you - so these will be indexed with the values 0, 1, and 2.
* happy coding and hope this works for you.