passing converted javascript array from php to javascript function -
i want pass javascript array(converted php js) present in php code javascript function.
<?php //php javascript array conversion $php_array = array('he','hi','hello'); $js_array = json_encode($php_array); echo 'var groups = ". $js_array . ";\n'; ?> function codeaddress(groups) { alert("into code address function"); (var i=0;i<groups.length;i++) { alert(groups[i]); } }
echo 'var groups = '. $js_array . ";\n";
variable not expanded inside single quotes. don't put output of json_encode quotes.
Comments
Post a Comment