php - How to reformatted array -
i have array indexes like
$array = array( "first_name" => "test", "last_name" => "testsurename" );
i need convert to:
$array = array( "0" => array("first_name" => "test"), "1" => array("last_name" => "testsurename") );
try this,
$array = array("first_name"=>"test","last_name"=>"testsurename"); $newarray = array(); foreach($array $key=> $val) { $newarray[][$key] = $val; } print_r($newarray);
output :
$array = array( "0" => array("first_name" => "test"), "1" => array("last_name" => "testsurename") );
Comments
Post a Comment