PHP array convert to Java Script array
Sometimes when we using php, we want to convert php array to java script array.php array can be convert to java script easily.Here is a easy and best methods to do this.
PHP provides json_encode() function to convert PHP arrays into Java Script code.
$php_array = array('id','username','email');
This can be convert to java script as follows.
Note:json_encode()
id [1] => username [2] => email ) */ $js_array = json_encode($php_array); print_r($js_array); /* Apply json_encode() ["id","username","email"] */ ?>
What's your reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0