PHP - JSON编码土耳其语字符随着奇怪的字符而变化

I am working on json array but Turkish characters change with strange characters. For example:

  • ı -> ı, sometimes ý (it is too weird)
  • ü -> ö,
  • İ -> ý

...

What I tried?

 header('content-type: application/json; charset=utf-8');

 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

 iconv("ISO-8859-1", "UTF-8",$str)

I tried seperately all of them but didn't solve the problem. How can I fix this? Here is my code:

foreach($html->find('table//tbody//tr//td') as $element) {


    $elm = strip_tags($element->innertext);

    //echo $str."<br>";
    if($str != "&nbsp;"){
        $tmp[] = iconv("ISO-8859-1", "UTF-8",$str);

    } else {
        $lessons["lesson"][] = $tmp;
        unset($tmp);
        $temp = array();
    }

}

$json = json_encode($lessons,JSON_UNESCAPED_UNICODE);

print_r($json);

you must databese charset utf8

PDO JSON Code Example

view details

<?php
header('Content-Type: application/json');


try{
    $db = new PDO("mysql: host=localhost; dbname=veritabani; charset=utf8","root","mysql");
}catch(PDOException $message){
    echo $message->getMessage();
}


$query = $db->prepare("SELECT id,product_name,product_price,delivery_date FROM teklif ORDER BY id");
$query->execute();
$data = $query->fetchAll(PDO::FETCH_ASSOC);





echo json_encode($data,JSON_UNESCAPED_UNICODE);