I've got a multidemnsional array as an object in PHP and like to print it in Javascript. This is as for I've reached.
PHP:
$words = $wordlist->getWordlist($var1,$var2);
Now i usually printed the array like this in PHP:
foreach ($words as $section => $items)
foreach ($items as $key => $value)
echo "$key\t = $value";
This is what I'm trying to do in Javascript:
var coders= <?php print json_encode($words); ?>;
for(var i = 0, l =coders.length; i < l; i++) {
for(var j = 0, l2 = coders[i].length; j < l2; j++) {
var value = coders[i][j];
document.write(value);
}
}
This is my result when i print:
document.write(coders);
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thanks!