romain.pelissier Posted August 2, 2007 Share Posted August 2, 2007 Hi, I am stuck with what it seems to me a simple problem and I need some help. I am very new php programmer ... I am pretty sure that you experts can give me the answer in few words.. Here it is : I have a multidimensional array that looks like this : Array ( [2007] => Array ( [0] => Array ( [mois] => 7 [path] => /var/www/html/rapports/ARCHIVES/2007/7 ) [1] => Array ( [mois] => 6 [path] => /var/www/html/rapports/ARCHIVES/2007/6 ) ) [2006] => Array ( [0] => Array ( [mois] => 1 [path] => /var/www/html/rapports/ARCHIVES/2006/1 ) ) ) As you can see, the indexes are a number : 2007, 2006, ... and each item of those keys contains an array with other items like a path and a number : 2007 0 path : /var/www/html/rapports/ARCHIVES/2007/ month : 7 1 path : /var/www/html/rapports/ARCHIVES/2007/ month : 6 2006 0 ... Now, if I know my index number (let say 2007) is there a way to retrieve the entire sub-array for that particular key so I can have in a array the values for the key I have choosed ? I hope you could answer me. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/63083-solved-retreive-sub-arrays-in-a-multidimensional-array-need-help/ Share on other sites More sharing options...
premiso Posted August 2, 2007 Share Posted August 2, 2007 <?php $array_2007 = $main_array[2007]; print_r($array_2007); ?> Quote Link to comment https://forums.phpfreaks.com/topic/63083-solved-retreive-sub-arrays-in-a-multidimensional-array-need-help/#findComment-314159 Share on other sites More sharing options...
romain.pelissier Posted August 2, 2007 Author Share Posted August 2, 2007 Thanks premiso, That works the way I wanted, thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/63083-solved-retreive-sub-arrays-in-a-multidimensional-array-need-help/#findComment-314169 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.