+ 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 Respostas
+ 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 накой то...
вместо вывода...