Convert php array to javascript array
Create php array first,
<?php
$arrPhp=array("1","2","3","4","5');
?>
Create javascript array second
<script>
var arrJava=new Array();
</script>
Now assign php array value to javascript array value
<script>
<?php
for($i=0;$i<count($arrPhp);$i++)
echo "arrJava[".$i."]=".$arrPhp[$i].";";
?>
</script>
the php array now assigned to javascript array.
0 comments:
Post a Comment