I've tried to move a php array to a javascript array. this is what I 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 some reason, when I open the google chrome debuger, and check what cities is, this is what I get:
<script type='text/javascript'> var cities = ["אזעקה בבני ברק"," גבעתיים"," חוות שלם"," רמת גן"];</script>
I don't know why it's decoding. I have php 5.6.
Later I tried just moving a normal variable and even when I move a normal variable (without json_encode) it becomes like that
I used those examples:
Convert php array to Javascript
Passing utf-8 strings between php and javascript
Thanks!