Possible Duplicate:
Best method for converting a PHP array to javascript
I am trying something like this:
<script>
var product_name = new array();
<?php
foreach($products as $key=>$value) {
echo "product_name[] = $key";
}
?>
</script>
But I could not convert the PHP array to a Javascript array.
json_encode()
instead :)