Yes, using json is another option, here is a sample code
PHP Code:
<?PHP
$arr = array('one' => 'orange', 'two' => 'apple', 'three' => 'peach', 'four' => 'rose');
$str = (json_encode($arr)); ?>
<script> var s = '<?PHP echo $str; ?>'; var obj = eval("(" + s + ")"); alert(obj.one); </script>
But json only available since PHP 5.2.0
__________________
There is no secret ingredient.
Last edited by phpdasan; 08-10-2010 at 06:33 AM..
|