Когда очень нужно JSON ответ в PHP 🙃
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
$jsonString = "ok;"; $jsonString .= "["; while ($dados = $sql1->fetch_array()) { $jsonString .= "{"; $jsonString .= "\"id\":\""; $jsonString .= $dados['id']; $jsonString .= "\","; $jsonString .= "\"cpf\":\""; $jsonString .= $dados['cpf']; $jsonString .= "\","; $jsonString .= "\"nome\":\""; $jsonString .= $dados['nome']; $jsonString .= "\","; $jsonString .= "\"tipo\":\""; $jsonString .= $dados['tipo']; $jsonString .= "\""; $jsonString .= "},"; } $jsonString = rtrim($jsonString, ','); $jsonString .= "]"; echo $jsonString; |