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 :: php json string to associative array 
Php :: php case switch 
Php :: php sum array of objects 
Php :: php unset array element 
Php :: php get total amount of days in month 
Php :: max_execution_time php 
Php :: interface x trait in php 
Php :: php number to color 
Php :: server cmd php 
Php :: php turney if 
Php :: php json_encode 
Php :: append file in php 
Php :: how to separate integer from string in php 
Php :: strval in php 
Php :: upload file in laravel 
Php :: php get highest key value 
Php :: carbon difference between two dates 
Php :: count remaining days php 
Php :: laravel required_with 
Php :: count words in string php 
Php :: laravel in array blade 
Php :: php copy 
Php :: php weekdays 
Php :: How to get a WordPress post by slug 
Php :: mysqli last index php 
Php :: laravel get request check 
Php :: php check if any of multiple values in array 
Php :: guzzlehttp form data 
Php :: mac address php 
Php :: file put contents append 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =