I have a multidimensional array and would like to call the key and the value separately, of individual levels inside the array.
Now with a normal array, I can do this by writing:
$example = array('one', 'two', 'three');
echo $example[0];
and this will return: one
However, when I try to do this with a multidimensional array like so:
$example = array(
'optionone' => array('one', 'two', 'three'),
'optiontwo' => array('a','b','c'),
'optionthree' => array(1,2,3)
);
echo $example[0];
echo $example[0][0];
Instead of echoing 'optionone' followed by 'one' I get nothing returned, and no error code.
When trying to see why this is happening by using:
var_dump($example[0)];
or
var_dump($example[0][0]);
NULL is returned.
I would really appreciate if someone could tell me how to correctly get/echo/call 'optionone' to return from the array as a string: 'optionone' without writing the name and how can I call the value 'one' without writing:
$example['optionone'][0];
I'm trying to create something where it doesn't know the key name, so it rather is going by the position of the keys but i would like to be able to return the key names at different points in the program but I can't seem to figure out how to do this.
array_keysfunction