<?php $phpArray = array( 0 => "hiox.com", 1 => "hiox.org", 2 => "hscripts.com", 3 => "hibihi.com"); ?> <script> var jsArray = new Array(); <?php foreach( $phpArray as $key=>$value ) { ?> jsArray['<?=$key;?>'] = '<?=$value;?>'; <?php } ?> alert(jsArray); </script>"jsArray" will contain the same array as "phpArray".