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. Link to comment https://forums.phpfreaks.com/topic/62088-solved-array-inside-array/ 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. Link to comment https://forums.phpfreaks.com/topic/62088-solved-array-inside-array/#findComment-309107 Share on other sites More sharing options...
aQ Posted July 27, 2007 Author Share Posted July 27, 2007 It only echoes "[0]"... Any ideas? Link to comment https://forums.phpfreaks.com/topic/62088-solved-array-inside-array/#findComment-309112 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") ); Link to comment https://forums.phpfreaks.com/topic/62088-solved-array-inside-array/#findComment-309113 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 ?> Link to comment https://forums.phpfreaks.com/topic/62088-solved-array-inside-array/#findComment-309121 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. Link to comment https://forums.phpfreaks.com/topic/62088-solved-array-inside-array/#findComment-309125 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.