php - How to re-arranging an array -
i having , issue rearrange array, try of them.. try use array_merge, foreach, forloop, while loop etc. no luck
my concept not clear need idea how can change array per requirements, batter if give me concept idea only, don't required code try self first code it.
here array
array ( [links] => array ( [song_name] => array ( [0] => aa [1] => bb [2] => cc ..... ) [singer_name] => array ( [0] => aa [1] => bb [2] => cc ..... ) [song_url_320] => array ( [0] => aa [1] => bb [2] => cc ..... ) [song_url_128] => array ( [0] => aa [1] => bb [2] => cc ..... ) ) )
i need change array this:
array ( [links] => array ( [0] => array ( [song_name] => aa [singer_name] => aa [song_url_320] => aa [song_url_128] => aa ..... ) [1] => array ( [song_name] => bb [singer_name] => bb [song_url_320] => bb [song_url_128] => bb ..... ) [2] => array ( [song_name] => cc [singer_name] => cc [song_url_320] => cc [song_url_128] => cc ..... ) ) )
idea: loop through items , combine them array
here sample code:
$inputarray = array(...); $outputarray = array('links' => array()); foreach ($inputarray['links'] $k => $v) foreach ($v $k2 => $v2) { $outputarray['links'][$k2][$k] = $v2; }
Comments
Post a Comment