Skip to content
PHP Logo

How can arrays be used to output a name in PHP?

To output a name using arrays in PHP, you can store the name in an array variable and then access it using the array index. This allows for easy retrieval and manipulation of the name within your PHP code.

php
<?php
$name = "John";
$nameArray = array($name);

echo $nameArray[0]; // Output: John
?>