Reputation:
I have this array
<?php
$themename = "So";
$shortname = "se";
$options = array (
array( "name" => "the_firstname",
"desc" => "The firstname of a person",
"id" => $shortname."_the_firstname",
"type" => "text",
"value" => ""),
array( "name" => "the_lastname",
"desc" => "A persons lastname",
"id" => $shortname."_the_lastname",
"type" => "text",
"value" => ""),
);
foreach($options as $key => $value)
{
echo $value['id']."<br/>";
}
?>
with similar keys for instance the id
key.I would like to access the id
value of the first array.
Doing this echo $value['id'][0]."<br/>";
or echo $options['id'][0]."<br/>";
isn't helping.
How can i show the value of the first id
?.
Upvotes: 3
Views: 51
Reputation: 42915
echo $options[0]['id'];
should do the trick on top level, inside the for
loop this should work: $value['id']
. You don't need the [0]
here, since $value
contains the first (0) element inside the $options
array.
Upvotes: 2