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. Quote Link to comment 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.. Quote Link to comment 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]; } Quote Link to comment 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! 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.