$salida = '
<script language="JavaScript">
function get_form(){
var matriz_js = new Array ();';
[code=php]$matriz_php = array(4,6,8);
for ($i = 0; $i < count($matriz_php); $i++) {
$salida.= "matriz_js [" + $i +"] = " + $matriz_php [$i];
}[/code]
$salida .= 'alert(matriz_js[1]);
}';
it doesn't works. matriz_js[1] or whatever index = undefined
edit
I have been trying things.
now I have this:
$matriz_php = array(4,6,8);
for ($i = 0; $i < count($matriz_php); $i++) {
$salida.="matriz_js [\" $i \"] = ". $matriz_php[$i];
}
JavaScript Console shows me this:
Error: missing ; before statement
Línea: 191, columna: 23
Código fuente:
matriz_js [" 0 "] = 4matriz_js [" 1 "] = 6matriz_js [" 2 "] = 8alert(matriz_js[0]);
so, I change my code just like this:
$matriz_php = array(4,6,8);
for ($i = 0; $i < count($matriz_php); $i++) {
$salida.="matriz_js [\" $i \"] = ". $matriz_php[$i].";";
}
...but it's the same like before, matriz_js[0] is undefined 🙁
please help me