Answers for "how to use php loop inside javascript script"

PHP
1

javascript php loop

<?php
$s=array('a','b','c','d','e','f');
$s_to_json=json_encode((array)$s);
?>

<script type="text/javascript">

var fromPHP=<? echo $s_to_json ?>;

for (i=0; i<fromPHP.length; i++) {

yourValue=fromPHP[i];

}

</script>
Posted by: Guest on July-27-2020

Code answers related to "how to use php loop inside javascript script"

Browse Popular Code Answers by Language