- json_decode: documentation ( source)
- json_encode: documentation ( source)
<?php
$str = '[
{
"id": "1087",
"name": "Abhishek Saini",
"email": "info@gmail.com",
"gender": "male"
},
{
"id": "1088",
"name": "Gourav",
"email": "test@gmail.com",
"gender": "male"
}
]';
$json = json_decode($str, true);
$json = array('users' => $json);
echo json_encode($json, JSON_PRETTY_PRINT);