What are some best practices for utilizing explode to extract the last item in a string?

When using explode to extract the last item in a string, it is important to remember that explode returns an array of substrings. To get the last item, you can use the negative index -1 to access the last element in the array. This can be helpful when dealing with strings that have a delimiter separating different parts.

$string = "apple,banana,orange";
$items = explode(",", $string);
$lastItem = end($items);
echo $lastItem;