rasherb Posted December 19, 2008 Share Posted December 19, 2008 Hi! I have an array sort of like this example I found: $cds = array( 'Christina Aguilera'=>array( 'Impossible', 'Beautiful', 'Dirrty' ), 'Pink'=>array( 'Just like a pill', 'Family potrait', 'Missundaztood' ), 'Kelly Rowland'=>array( 'Stole', 'Obsession', 'Past 12' ) What I need to do is pull off all of the, for example, 'Pink' albums and make a single array from those values. This is my real array: $importarray[$i][$m] I need to make an array of all the sub-values ($m) at a certain value of $i. What can I do? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/137688-solved-multidimensional-array-make-single-array/ Share on other sites More sharing options...
Adam Posted December 19, 2008 Share Posted December 19, 2008 Try this.. <?php // array defined here $key = array_search('Pink', $cds); if ($key !== false) { foreach ($cds[$key] as $cd) { $matchedCDs[] = $cd; } } print_r($matchedCDs); ?> A Quote Link to comment https://forums.phpfreaks.com/topic/137688-solved-multidimensional-array-make-single-array/#findComment-719654 Share on other sites More sharing options...
rasherb Posted December 19, 2008 Author Share Posted December 19, 2008 OOOH. Nice. I'll give it a try. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/137688-solved-multidimensional-array-make-single-array/#findComment-719659 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.