How can you retrieve only the first entry from an array in PHP?
To retrieve only the first entry from an array in PHP, you can use the array_shift() function. This function removes and returns the first element of the array, effectively retrieving only the first entry. It is a simple and efficient way to access the first element of an array without modifying the original array.
$myArray = [1, 2, 3, 4, 5];
$firstEntry = array_shift($myArray);
echo $firstEntry; // Output: 1