Json does not return with UTF-8

0

I'm trying to turn the array from Mysql into a Json so I can use it in AJAX in> but whenever the bank returns some field that has accents the json is not returned, however when decoding it using utf8_decode () json > is returned without the accents, what can I do to resolve this problem?

Code without utf8_decode ():

<?php

require_once('connection.php');

$query = "SELECT U.* , (SELECT COUNT(*) FROM uniforms u0 where u0.GROUP_ID = U.ID ) as AMOUNT from uniforms_group U";


$result = mysqli_query($connection,$query);


$rows= array();

echo mysqli_error($connection);

while($sonuc = mysqli_fetch_assoc($result)) {

    array_push($rows,$sonuc);
}


echo json_encode($rows);
?>

Answer:

Codewithutf8_decode():

<?phprequire_once('connection.php');$query="SELECT U.* , (SELECT COUNT(*) FROM uniforms u0 where u0.GROUP_ID = U.ID ) as AMOUNT from uniforms_group U";


$result = mysqli_query($connection,$query);


$rows= array();

echo mysqli_error($connection);

while($sonuc = mysqli_fetch_assoc($result)) {
    $sonuc['PLACE'] = utf8_decode($sonuc['PLACE']);
    array_push($rows,$sonuc);
}


echo json_encode($rows);
?>

Answer:

    
asked by anonymous 01.02.2018 / 19:48

0 answers