Php In Javascript Is It Possible
The headline is properly pretty bad, but i don't know what to name it.. Anyways: I have this simple problem with a javascript code that i want to display some php code, but i don't
Solution 1:
add this tag on your html file
<scripttype="text/javascript"src="/javascript.php"></script>
in your javascript.php file:
<?php
header("Content-Type:text/javascript");
$arr = array();
echo'var array_data = [';
for( $i = 0; $i < 10; $i++ ){
$arr[] = "[{$i},'Team {$i}']";
};
echo implode(",",$arr);
echo']';
then in your js file you will have a js array called array_data
then you can iterate over it
Post a Comment for "Php In Javascript Is It Possible"