Transmettre un tableau php à un script JS
Bonjour,
La FAQ PHP : Comment afficher du texte ? indique comment transmettre une variable php à un script JS.
L'exemple donné concerne une variable texte, mais comment transmettre un tableau?
J'ai fait l'essai suivant qui me retourne une magnifique erreur Array to string conversion:
Code:
1 2 3 4 5 6 7 8 9
|
<?php
//var_dump($joursCal);
print '<script type="text/javascript" language="javascript">';
//print "alert('$champ[texte]');";
print "var joursCal[] = '$joursCal', moisCal = '$moisCal';";
print "alert(joursCal, moisCal);";
print '</script>' ;
?> |