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 = ["אזעקה בבני ברק"," גבעתיים"," חוות שלם"," רמת גן"];</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:
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
Post a Comment