I need to mount a JSON
, in PHP
, to return data to AngularJS, but one of the JSON
object's data is coming with the letter "á" with another character. How can I fix this?
NOTE: The name is accented in the BD, because it was inserted in the DB with an accent. DB is configured with utf8-bin.
My php:
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
header('Access-Control-Allow-Origin: *');
header('Content-Type: text/html; charset=utf-8');
include_once("conPDO.php");
$pdo = conectar();
$idUsuario = $_GET['idUsuario'];
$pegaUsuario=$pdo->prepare("SELECT * FROM usuarios WHERE idUsuario=:idUsuario");
$pegaUsuario->bindValue(":idUsuario", $idUsuario);
$pegaUsuario->execute();
$return = array();
while ($linha=$pegaUsuario->fetch(PDO::FETCH_ASSOC)) {
array_push($return, $linha);
}
print_r($return[0]);
//echo json_encode($return[0]);
? >
And see how object json appears on the console, see the name.