how to convert Javascript string array to PHP, it will processed in the server not client side
<?php
$str = 'var str_array = ["aa", "bb"]';
$str = str_replace("var ", '$', $str);
eval($str);
print_r($str_array);
Demographics. Technologies. Salaries. Career satisfaction.
how to convert Javascript string array to PHP, it will processed in the server not client side
|
||||
Eval() should end with
Output:
But I don't know why you opt for this. |
|||||
|
Post your javascript array as a JSON string via ajax and process it server-side. Javascript
PHP (test.php)
|
|||
|
print
of array usingprint_r
– Maninderpreet Singh May 5 '16 at 5:50eval($str);
intoeval("$str;");
– Narendrasingh Sisodia May 5 '16 at 5:53