I got a php file that manages a entity in my database. What I want to do is to retrieve a set of strings from the database and return it via json_encode to a javascript function.
The problem is that when the php script retrieves the values the accented chararters are displayed fine.
When I output it like this:
echo "<pre>";
print_r($row);
echo "</pre>";
I get:
Array
(
[0] => 1
[1] => Que és la bolsa de trabajo de la FIB?
)
But when I want to return the data to the ajax call via json_encode I get this:
["1","Que \u00e9s la bolsa de trabajo de la FIB?"]
What I am doint to de data beore output it in the json_encode is:
function encode_items(&$item, $key)
{
$item = utf8_encode($item);
}
array_walk_recursive($stack, 'encode_items');
echo json_encode($stack);
Any idea on how to codify it correctly ?? I asume that if is shows properly in my echo in PHP it will show fine in my javascript ajax call, am I right ?
thanks