charles.ca Posted October 15, 2010 Share Posted October 15, 2010 Hi .. i have an array format like (mysql result array) $new_array=Array ( [0] => Array ( [quantity] => 5 ) [1] => Array ( [quantity] => 25 ) [2] => Array ( [quantity] => 20 ) ) I have to convert this array into the following format $new_array['quantity'][0]=5 $new_array['quantity'][1]=25 $new_array['quantity'][2]=20 How to convert this array format using any standard array method. Link to comment https://forums.phpfreaks.com/topic/215937-how-to-exchange-array-keys/ Share on other sites More sharing options...
Adam Posted October 15, 2010 Share Posted October 15, 2010 There is no standard PHP function to do that. You can use a loop though: $seomthing = array(); foreach ($new_array as $key => $value) { $something['quantity'][$key] = $value['quantity']; } print_r($something); Link to comment https://forums.phpfreaks.com/topic/215937-how-to-exchange-array-keys/#findComment-1122456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.