I have a problem to get in a session array from php into a javascript
I´m setting the sessions array here, the print_r is only for checking so it´s correct
while($row2[]=mysql_fetch_array($result2))
$_SESSION['row2'] = $row2;
print_r($_SESSION['row2'][0][0]);
print_r($_SESSION['row2'][0][1]);
print_r($_SESSION['row2'][0][2]);
and in my javascript i use this, alert is only for checking
var row2 =<?php echo json_encode($_SESSION['row2']) ?>;
alert (row2[0][0]);
alert (row2[0][1]);
alert (row2[0][2]);
row2[0][0] and row2[0][1], works fine, I get the numbers from the array
but row2[0][2] give me the value null, it should be some text in this field, it´s works fine with print_r($_SESSION['row2'][0][2]); in the php-code.
use firebug console or chrome console. After that dump the entire
row2into the console and preview the data.Also, keep in mind that all PHP associative arrays will become JSON object and should be accessed with
.