What are some potential pitfalls to be aware of when using the explode function in PHP?

One potential pitfall when using the explode function in PHP is that it may return an empty array if the delimiter is not found in the input string. To avoid this issue, you can check if the returned array is empty before trying to access its elements.

$input_string = "Hello World";
$delimiter = ",";
$exploded_array = explode($delimiter, $input_string);

if (!empty($exploded_array)) {
    // Access elements of the exploded array
    // Example: echo $exploded_array[0];
} else {
    echo "Delimiter not found in input string.";
}