Passing a PHP array to Javascript

PHP array:


$fruits = array("Apple","Mango","Banana");

convert $fruits to Javascript array


echo 'var fruits = new Array("',join($fruits,'","'),'");';


The above statement will convert PHP array to Javascript array. This saves a lot of time.

0 comments



Some Links (off programming)