/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $arreglo = array( 'clave 1' => 'valor 1', 'clave 2' => 'valor 2', 'clave x' => 'valor x', ); ?> <script language="javascript"> var arr = { <?php foreach($arreglo as $key => $values){ $arr .= "'" . $key . "'" . " : " . "'" . $values . "'" . ","; } $arr = substr_replace($arr, '', -1); echo $arr; ?> }; </script>
Comments
