Reputation: 11
I am getting error Uncaught SyntaxError: Unexpected identifier
on line : TableX[i] = <?php echo $TableX[$x]; ?> ;
In the code below :
index.php
for( i = 1 ; i<= <?php echo $num;?> ; i++)
{
<?php for($x = 1 ; $x<=$num ; $x++ ) { ?>
TableX[i] = <?php echo $TableX[$x]; ?> ;
TableY[i] = <?php echo $TableY[$x]; ?> ;
}
<?php } ?>
I've wasted enough time on this , help would be really appreciated .
Upvotes: 0
Views: 471
Reputation: 17762
You can just output a php array as JSON:
<script>
var TableX = <?php echo json_encode($TableX);?>
Upvotes: 1