Wednesday, 18 April 2018

json_decode utf issue php


function dataJSON($inputs) {
 //This will convert ASCII/ISO-8859-1 to UTF-8.
 //Be careful with the third parameter (encoding detect list), because
 //if set wrong, some input encodings will get garbled (including UTF-8!)
 //$imput = mb_convert_encoding($inputs, 'UTF-8', 'ASCII,UTF-8,ISO-8859-1');
 //Remove UTF-8 BOM if present, json_decode() does not like it.
 if(substr($inputs, 0, 3) == pack("CCC", 0xEF, 0xBB, 0xBF)) $inputs = substr($input, 3); return $inputs;
}
$ReadPathJsonFile = site_url().'jsonFile.json';  // your json file path
$dataGet = file_get_contents($ReadPathJsonFile);

$jsonDecode = json_decode(dataJSON($dataGet), true);
//you can check the data
print_r($jsonDecode);
-------------------------------------------------

Let me know your thoughts and questions in the comments.
Email: vyasankit2008@gmail.com 

2 comments:

  1. oh i see code working perfect, thanks man...

    ReplyDelete
  2. Welcome....i will create new more interesting posts next few days.

    ReplyDelete