Search
 
SCRIPT & CODE EXAMPLE
 

PHP

assign php array into javascript

<script type="text/javascript">

	$(document).ready(function() {
      FACILITY_BOOKING.lst_festival_day = new Array();
      <?php foreach($festival_day as $key => $val) { ?>
        FACILITY_BOOKING.lst_festival_day.push('<?php echo $val; ?>');
      <?php } ?>
    });
</script>
Comment

Passing PHP Arrays to JavaScript

<?php
// php array
$fruits = array('apple', 'orange', 'mango', 'banana', 'strawberry');
?>
<script type="text/javascript">
// use php implode function to build string for JavaScript array literal
var fruits = <?php echo '["' . implode('", "', $fruits) . '"]' ?>;
// ["apple", "orange", "mango", "banana", "strawberry"]
</script>
Comment

Passing PHP Arrays to JavaScript

var ar = <?php echo '["' . implode('", "', $ar) . '"]' ?>;
Comment

PREVIOUS NEXT
Code Example
Php :: laravel select only some columns relationship 
Php :: wordpress escape string 
Php :: how to get last id in database 
Php :: php binary to base64 
Php :: comment in php 
Php :: changing created_at to short date time 
Php :: laravel truncate string laravel 8 
Php :: php extract array 
Php :: magento2 set session timeout cia cli 
Php :: laravel observer events 
Php :: brew install php 5.6 
Php :: how to get week start date in php 
Php :: filter validate email php 
Php :: report simple error in php 
Php :: add css to gutenberg editor 
Php :: full month name php 
Php :: laravel post request search query 
Php :: php force array keys trim 
Php :: PHP sqrt() Function 
Php :: php-curl 
Php :: mcrypt php extension required 
Php :: PHP Time Limit: 
Php :: php sort custom function 
Php :: how to stop laravel server 
Php :: print array in php 
Php :: laravel new line in language file 
Php :: wordpress 404.php redirect to home 
Php :: file_put_contents 
Php :: wordpress post type template 
Php :: Laravel Retrieve All Session Data 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =