What are the potential complications when using explode() in PHP?

One potential complication when using explode() in PHP is that it can throw a warning or error if the delimiter is not found in the input string. To avoid this, you should always check if the delimiter exists in the input string before using explode(). This can be done using strpos() to check if the delimiter is present in the input string.

$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";
}