Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

using a php array in jquery

<?php
	// PHP Array
  $names = array('John', 'Doe', 'Joe');
?>

<script>
  // Convert the data to JSON format
	let users = <?php echo json_encode($names); ?>;
	alert(users[0]); // It output John
</script>
 
PREVIOUS NEXT
Tagged: #php #array #jquery
ADD COMMENT
Topic
Name
9+5 =