aQ Posted July 27, 2007 Share Posted July 27, 2007 Hello! I have got an array. In this array, there are multiple arrays. I want to show some of the info in one of the arrays which are inside the main-array. It's like this: $array = Array( [test] => Test, [lala] => Array(with content in it).... ); I thought I just could say "print $array[lala][0];", and it would give me the first value of "lala" in the $array. This does not work, so how can I do it then? Thank you. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 27, 2007 Share Posted July 27, 2007 Try printing it like this: <?php echo $array[1][0]; ?> I think that should give you the first element of lala. Quote Link to comment Share on other sites More sharing options...
aQ Posted July 27, 2007 Author Share Posted July 27, 2007 It only echoes "[0]"... Any ideas? Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted July 27, 2007 Share Posted July 27, 2007 $array = array ( "test" => "Test", "lala" => array(0 =>"first", 1 => "second") ); Quote Link to comment Share on other sites More sharing options...
Barand Posted July 27, 2007 Share Posted July 27, 2007 must be the way you defined the arrays <?php $array = array( 'test' => 'Test', 'lala' => array('unicorn', 'lion', 'dragon') ); echo $array['lala'][0]; // --> unicorn ?> Quote Link to comment Share on other sites More sharing options...
aQ Posted July 27, 2007 Author Share Posted July 27, 2007 I had put the array in "" like this: print "Value: $array[lala][value]"; When I removed the ""'s, it worked. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.