When I print an array with
print_r($item)
I get a result
Array(
[First Name] => Sam
[Gender] => 2
[Last Name] => Smith
)
But when I do echo $item['First Name']
I receive PHP notice undefined index. Why does it happen?
When I print an array with
print_r($item)
I get a result
Array(
[First Name] => Sam
[Gender] => 2
[Last Name] => Smith
)
But when I do echo $item['First Name']
I receive PHP notice undefined index. Why does it happen?
Make sure that you have this structure in the associative array:
$item = ['First Name' => 'Sam', 'Gender' => 2, 'Last Name' => 'Smith'];
echo $item['First Name'];
echo $item['First Name'];
will output: Sam