How can you retrieve the last character of an element in a PHP array?
To retrieve the last character of an element in a PHP array, you can use the substr() function to extract the last character of the string. First, access the desired element in the array, and then apply the substr() function with a negative index to retrieve the last character. This negative index indicates counting from the end of the string.
// Sample PHP array
$array = ["apple", "banana", "cherry"];
// Access the desired element and retrieve the last character
$lastCharacter = substr($array[1], -1);
echo $lastCharacter; // Output: a