2016-05-08 6 views
0
$files = array(); 
$dir = opendir(dirname(realpath(__FILE__)).'/files/'.$fil_fi_row['file_name'].'/'); 
while ($file = readdir($dir)) { 
    if ($file == '.' || $file == '..') { 
     continue; 
    } 
    $allfiles[] = $file; 
} 

$total_arr=array_merge((array)$id,(array)$files); 
sort($total_arr); 
foreach($total_arr as $key=>$file){ 
    if($key != count($total_arr)-1) 
     $array[‘Files’][] = array(           
      ‘files’ => $file, 
      ‘id’ => $id, 
     ); 
    } 
} 
echo json_encode($array, JSON_UNESCAPED_UNICODE); 

Я пробовал JSON_UNESCAPED_UNICODE, но не работает; ОШИБКАjson_encode() не отображает арабские символы (opendir)

Notice: Use of undefined constant JSON_UNESCAPED_UNICODE - assumed 'JSON_UNESCAPED_UNICODE' in /home/... 

Warning: json_encode() expects parameter 2 to be long, string given in /home/.. 

Когда я использую

echo json_encode($array); 

имя Arabic файл выглядит как:

8508_\u0645\u0635\u0631 \u0627\u0643\u0631\u0645 20150908 
+0

'JSON_UNESCAPED_UNICODE' был введен с PHP 5.4 – mario

+1

показать содержимое '$ array' – RomanPerekhrest

+0

RomanPerekhrest посмотреть код сейчас ... спасибо – OsamahM

ответ

0

попробовать это (PHP5.4.0 +)

json_encode($result, JSON_UNESCAPED_UNICODE); 
+0

не работает (пустая страница) – OsamahM

+0

Это означает, что ваша версия PHP <5.4 –

Смежные вопросы