How to display only array value in JSON out in php
I am using below PHP code
echo '{"aaData":'.json_encode($user_details).'}';
And it return below output
{"aaData": [
{"id":"31","name":"Elankeeran","email":"[email protected]","activated":"0","phone":""}
]}
But I need JSON output like below
{"aaData": [
{"31","Elankeeran","[email protected]","0","1234"}
]}
Any one please help on this.
$rows = array();
foreach ($user_details as $row) {
$rows[] = array_values((array)$row);
}
echo json_encode(array('aaData'=> $rows));
which outputs:
{"aaData": [
["31","Elankeeran","[email protected]","0","1234"],
["33","Elan","[email protected]","1",""]
]}
echo '{"aaData":'.json_encode(array_values($user_details)).'}';
should do it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With