php - modifying a JSON data -
i want modify json data format using php.
i have array this:
array ( [0] => stdclass object ( [0] => thu apr 30 12:25:12 +0000 2015 ) [1] => stdclass object ( [0] => wed apr 15 21:57:05 +0000 2015 ) )
i have tried json_encode($data); coming this:
[{"0":"thu apr 30 12:25:12 +0000 2015"},{"0":"wed apr 15 21:57:05 +0000 2015"}]
but want format:
["thu apr 30 12:25:12 +0000 2015","wed apr 15 21:57:05 +0000 2015"]
what should ?
try function, pass array argument
function to_array_of_strings($data){ $result_array = array(); foreach($data $key => $object){ foreach($object $object_key => $object_value){ $result_array[] = $object_value; } } return $result_array; }
Comments
Post a Comment