Pass array to Javascript

$n = array('test','test2');
echo '<script type="text/javascript">';
echo 'var n = new Array("', join($n,'","'), '");';
echo 'alert(n[1]);</script>';

0 Comments

You must be logged in to post a comment.