What are some common pitfalls when using the explode function in PHP?

One common pitfall when using the explode function in PHP is not checking if the delimiter exists in the input string before using explode. This can result in errors or unexpected behavior if the delimiter is not found in the string. To solve this issue, you should always check if the delimiter exists in the input string before using explode.

$input_string = "Hello World";
$delimiter = ",";
if (strpos($input_string, $delimiter) !== false) {
    $result = explode($delimiter, $input_string);
    print_r($result);
} else {
    echo "Delimiter not found in input string.";
}