+ 3
How to move array from PHP to JS ?
We have $whole_arr associative array in php, and...we need it to move to wholeArr in js. We can use them both on same page. Any ideas?(exept saving it in invisible element and getting , that's not cool :D) (only using js ,php,html,css if needed.)
4 Answers
+ 2
<?php
$sts = array(
"one"=>"one text",
"two" => "two text",
"three" => "text three"
)
?>
<script>
var t= <?php echo json_encode($sts);?>
console.log(t)
</script>
works perfectš
+ 20
echo "<script>arr='".implode(",",$array)."'.split(',');</script>";
(...not tested...)
+ 1
@Yaroslav Pieskov
That's it :)
___
ŠŠ¾ŠæŠµŃ в ŃŠµŠ¼ коŃŃŠŗ...Š²Š¾Š·Š²ŃŠ°Ńал в ŠæŠµŃŠµŠ¼ŠµŠ½Š½ŃŃ Š² php накой ŃŠ¾...
вмеŃŃŠ¾ Š²ŃŠ²Š¾Š“а...