Why does this code say "not set"? What is array location 2 set as to make it say "set"? How can I approach this so I know if there is or isn't a value in location 2?
(sorry for lack of a good title, couldn't think of one)
Why does this code say "not set"? What is array location 2 set as to make it say "set"? How can I approach this so I know if there is or isn't a value in location 2?
(sorry for lack of a good title, couldn't think of one)
well it is set, perhaps you meant to check if it was empty()
you should probably have a look at : The type comparison tables
Answer is
Try this
array_key_exists(2, $r);
// or
!empty($r[2]);
For more accurate
$line = "a";
$r = explode("|",$line);
print_r($r);
if(!empty($r[2])) // or use if(array_key_exists(2, $r))
echo "array location [2] set";
else echo "array location [2] NOT set";