-1
I made an "api" to return the data in json format, however the record that contains accent, is displaying special characters.
Look at my code, what I could do, there’s some command I can add?
I tried to put some parameters in json_encode, but it didn’t work.
Please I really need this help! I’ve done a lot of research before coming here.
My server php is already in version 7
<?php
header('Content-type: application/json');
require_once('dbConnect.php');
mysqli_set_charset($conn, $charset);
$response = array();
$stmt = mysqli_prepare($conn, "SELECT codigo, estado FROM estados");
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
mysqli_stmt_bind_result($stmt, $codigo, $estado);
if (mysqli_stmt_num_rows($stmt) > 0) {
while (mysqli_stmt_fetch($stmt)) {
array_push($response, array("codigo" => $codigo,"estado" => $estado));
}
echo json_encode($response);
} else {
echo json_encode($response);
}
?>
The data is like this:
Imagine if you have 1 million results and you have to use array_map, plus Pog which solution hehe. I recommend the post https://answall.com/q/43193/4800
– Marcos Xavier