How to get value from php inside a javascript? -


in below script default values used. use values database <?php $user->location ?> i.e., want use users loaction data inside var states.

how do it?

 <script>     $(document).ready(function() {         var states = ['alabama', 'alaska', 'arizona', 'arkansas', 'california'   ]; </script> 

<?php     $ar = array('one', 'two', 1, false, null, true, 2 + 5);  ?>  <script type="text/javascript">   var ar = <?php echo json_encode($ar) ?>;   // ["one","two",1,false,null,true,7];   // access 4th element in array   alert( ar[3] ); // false </script> 

thank you!!


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -