Answers for "using a php array in jquery"

PHP
1

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>
Posted by: Guest on August-20-2021

Code answers related to "using a php array in jquery"

Browse Popular Code Answers by Language