Korzystanie z tablicy PHP w 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>
godfreysseki