PHP array to javascript array UTF-8 -


i've tried move php array javascript array. did:

$cities = "בני ברק, גבעתיים, חוות שלם, רמת גן";  $php_array = explode(',', $cities);  $js_array = json_encode($php_array,json_hex_apos|json_hex_quot);  echo "<script type='text/javascript'> var cities = ". $js_array . ";</script>"; 

for reason, when open google chrome debuger, , check cities is, get:

<script type='text/javascript'> var cities = ["&#1488;&#1494;&#1506;&#1511;&#1492; &#1489;&#1489;&#1504;&#1497; &#1489;&#1512;&#1511;"," &#1490;&#1489;&#1506;&#1514;&#1497;&#1497;&#1501;"," &#1495;&#1493;&#1493;&#1514; &#1513;&#1500;&#1501;"," &#1512;&#1502;&#1514; &#1490;&#1503;"];</script> 

i don't know why it's decoding. have php 5.6.

later tried moving normal variable , when move normal variable (without json_encode) becomes that

i used examples:

convert php array javascript

passing utf-8 strings between php , javascript

thanks!

first, save file utf-8 bom encoding. then, add json_unescaped_unicode option json_encode call.

$js_array = json_encode($php_array, json_hex_apos|json_hex_quot|json_unescaped_unicode); 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -