I read many many many posts on this subject and I tried many solutions and I can't convert this multi-array into a JSON string. This is what I see when I print_r($result):
Array ( [profiles] =>
Array ( [0] =>
Array ( [ID] => 00000000-0000-0000-0000-000000000001
[UserName] => Administrator GU
[Age] => 37
[CityStateCode] => Montréal
[OnlineSince] => En ligne depuis 6 heures 39 minutes
[IsPaying] => true
[LabelOnlineStatus] => En ligne
)
[1] =>
Array ( [ID] => ab3dd04e-5621-11e3-b448-103f0c805f5a
[UserName] => Guillaume Le Genie
[Age] => 68
[CityStateCode] => Montréal
[OnlineSince] => En ligne depuis 1 jour 9 heures
[IsPaying] => true
[LabelOnlineStatus] => Hors-Ligne
)
[2] =>
Array ( [ID] => 00000000-0000-0000-0000-000000000050
[UserName] => Baby-dragoon
[Age] => 25
[CityStateCode] => Québec
[OnlineSince] => En ligne depuis 5 jours 6 heures
[IsPaying] => true
[LabelOnlineStatus] => Hors-Ligne
)
)
)
I try this (with and without true parameter):
$result = json_encode($result, true);
$error = json_last_error_msg();
echo "[ERROR : $error]-----[$result]-----";
And I receive:
[ERROR : Malformed UTF-8 characters, possibly incorrectly encoded]-----[]-----
When I try this:
$result = json_encode(htmlspecialchars(utf8_encode($result)));
I receive:
Warning: utf8_encode() expects parameter 1 to be string, array given in /Applications/XAMPP/xamppfiles/htdocs/cdn/php/functionsv1.php on line 2839
[ERROR : No error]-----[""]-----
When I try this:
$result = json_encode(htmlspecialchars($result));
I receive:
Warning: htmlspecialchars() expects parameter 1 to be string, array given in /Applications/XAMPP/xamppfiles/htdocs/cdn/php/functionsv1.php on line 2839
[ERROR : No error]-----[null]-----
I'm really lost!
N.B. You see the language is French so we have a char with accent like éèàô etc...
The data provide from MySQL Database and database is set to:
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8');