What are some PHP functions that can be used to split a string based on a delimiter?
When you need to split a string in PHP based on a delimiter, you can use the `explode()` function. This function takes two parameters: the delimiter and the input string. It then returns an array of substrings created by splitting the input string based on the delimiter. Another option is the `preg_split()` function, which uses a regular expression pattern as the delimiter for splitting the string.
// Using explode() function
$inputString = "apple,banana,orange";
$delimiter = ",";
$splitArray = explode($delimiter, $inputString);
print_r($splitArray);
// Using preg_split() function
$inputString = "apple,banana,orange";
$delimiter = "/,/";
$splitArray = preg_split($delimiter, $inputString);
print_r($splitArray);