- rtrim: documentation ( source)
- stripslashes: documentation ( source)
- json_decode: documentation ( source)
- html_entity_decode: documentation ( source)
- json_encode: documentation ( source)
- header: documentation ( source)
<?php
$jsonString = '[{"salesid":130201411173700750}]';
// PHP code
$payments = json_decode(stripslashes(html_entity_decode(rtrim($jsonString, '\0'))), true);
$values = '';
foreach ($payments as $key => $value) {
$value = (object)$value;
if ($values != '') {
$values .= ',';
}
printResponse(false, "sales id: $value->salesid");
exit;
//more code omitted...
}
function printResponse($success, $data, $totalCount = 0) {
header('Content-Type: application/json;charset=UTF-8');
print json_encode((object)[
'success' => $success,
'data' => $data,
'totalCount' => $totalCount
]);
exit;
}