- version_compare: documentation ( source)
- str_replace: documentation ( source)
- json_encode: documentation ( source)
<?php
$array = array('text' => "<h1>Кириллический URL</h1>\n<p>This is Cyrillic URL example. Try <a class=js-as dir=rtl href=עברית>RTL עברית</a>.</p>\n");
if (version_compare(PHP_VERSION, '5.4', '>=')) {
$data = json_encode($array, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
} else {
$data = str_replace('\\/', '/', json_encode($array));
}
echo $data;