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 />'; } } ?> Link to comment https://forums.phpfreaks.com/topic/197363-array-related/ 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 Link to comment https://forums.phpfreaks.com/topic/197363-array-related/#findComment-1035937 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? Link to comment https://forums.phpfreaks.com/topic/197363-array-related/#findComment-1035972 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"; } Link to comment https://forums.phpfreaks.com/topic/197363-array-related/#findComment-1035980 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 />'; } } ?> Link to comment https://forums.phpfreaks.com/topic/197363-array-related/#findComment-1035987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.