ram4nd Posted April 2, 2010 Share Posted April 2, 2010 $title comes as Array, but I need to print the value <?php $array = array( 'php'=>array('cms','frameworks'), 'blender'=>array('modeling','animation') ); foreach($array as $title) { echo $title.'<br />'; foreach($title as $links) { echo $links.'<br />'; } } ?> Quote Link to comment Share on other sites More sharing options...
ram4nd Posted April 2, 2010 Author Share Posted April 2, 2010 hmm the question is how to print key name Quote Link to comment Share on other sites More sharing options...
ram4nd Posted April 2, 2010 Author Share Posted April 2, 2010 Or are there a better way to do this? I mean keeping data in array like that. Like subcategories under categories? Quote Link to comment Share on other sites More sharing options...
xX_SuperCrazy_Xx Posted April 2, 2010 Share Posted April 2, 2010 You can do something like this in order to print the key value foreach ($array as $key => $value) { echo "$key => $value\n"; } Quote Link to comment Share on other sites More sharing options...
ram4nd Posted April 2, 2010 Author Share Posted April 2, 2010 solved it myself like: <?php $arrays = array( array('php', 'cms','frameworks','frameworks'), array('blender', 'modeling','animation') ); foreach($arrays as $array) { echo $array[0].'<hr />'; $count = count($array); for($i = 1;$i < $count; ++$i) { echo $array[$i].'<br />'; } } ?> 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.