ninka Posted March 26, 2007 Share Posted March 26, 2007 Hi all! I have an array that looks like this: Array ( [0] => Array( [fieldID] => 001 [description] => Hi all!) [1] => Array ( [fieldID] => 002 [description] => It’s me again! ) ) And I want to change it into array that would look like this: Array ( 001 => Hi all! 002 => It’s me again! ) Is it possible to do it at all? Can I would really appreciate, if someone could help me? I’m quite new in all this php stuff and still have a lot to learn. Link to comment https://forums.phpfreaks.com/topic/44315-solved-multidimensional-array/ Share on other sites More sharing options...
btherl Posted March 26, 2007 Share Posted March 26, 2007 $new_arr = array(); foreach ($orig as $o) { $new_arr[$o['filedID']] = $o['description']; } That ought to work.. Link to comment https://forums.phpfreaks.com/topic/44315-solved-multidimensional-array/#findComment-215223 Share on other sites More sharing options...
jitesh Posted March 26, 2007 Share Posted March 26, 2007 $new_arr = array(); for($i=0;$i<count($array);$i++){ $new_arr[$array[$i][fieldID]] = $array[$i][Description]; } Link to comment https://forums.phpfreaks.com/topic/44315-solved-multidimensional-array/#findComment-215233 Share on other sites More sharing options...
ninka Posted March 26, 2007 Author Share Posted March 26, 2007 Thanks a lot! It works perfectly and does the job! Link to comment https://forums.phpfreaks.com/topic/44315-solved-multidimensional-array/#findComment-215251 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.