Answers for "jquery javascript read php array"

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

Browse Popular Code Answers by Language