<?php
$jsonString = '[["7155206488121","Size","700C","",""],["","","26""]]';
$data = json_decode($jsonString);
if ($data === null && json_last_error() !== JSON_ERROR_NONE) {
echo "JSON decoding failed with error: " . json_last_error_msg();
} else {
var_dump($data);
}
?>
how to fix this problem.
I see output like this
<?php
$data = array(
array("7155206488121","Size","700C","",""),
array("","","26"")
);
print_r($data);
?>
A special character issue is occurring while decoding JSON.
I have tried three which are below.
try 1 :
<?php
$jsonString = preg_replace('/[[:cntrl:]]/', '', $jsonString);
$data = json_decode($jsonString, true);
?>
try 2 :
<?php
$jsonString = iconv('UTF-8', 'UTF-8//IGNORE', $jsonString);
$data = json_decode($jsonString, true);
?>
try 3 :
<?php
if (!mb_check_encoding($jsonString, 'UTF-8')) {
$jsonString = mb_convert_encoding($jsonString, 'UTF-8');
}
$data = json_decode($jsonString, true);
?>
I have tried three it doesn’t work.
If you don’t understand my question, read the message again calmly.