Leandro Garcia
Leandro Garcia

Reputation: 3228

What type of data is showing on console.log?

I'm wondering what type of data is the like of this:

enter image description here

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

Answers (2)

<?php $phpArray = array(
          0 => "36", 
          1 => "45"
    )
?>
<script type="text/javascript">
    var jArray= <?php echo json_encode($phpArray ); ?>;
</script>

Refrences

json_encode

array in php

Upvotes: 1

icktoofay
icktoofay

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

Related Questions