Reputation: 3228
I'm wondering what type of data is the like of this:
I want to generate one properly in PHP, because that is the required type of a parameter in a certain JS function.
Is it a string, array, object?
Upvotes: 0
Views: 83
Reputation: 57105
<?php $phpArray = array(
0 => "36",
1 => "45"
)
?>
<script type="text/javascript">
var jArray= <?php echo json_encode($phpArray ); ?>;
</script>
Refrences
Upvotes: 1
Reputation: 129109
That's an array of strings. You can generate one in PHP using json_encode
:
echo json_encode(array("36", "45"));
// => ["36", "45"]
Upvotes: 3