How can the explode function in PHP be used to split a string based on a specific character?
To split a string based on a specific character in PHP, you can use the explode function. The explode function takes two parameters - the delimiter character you want to split the string by and the string itself. It then returns an array of substrings that were separated by the delimiter character.
$string = "apple,banana,orange";
$delimiter = ",";
$fruits = explode($delimiter, $string);
foreach ($fruits as $fruit) {
echo $fruit . "<br>";
}
Related questions
-
jpgraph PHP x axis
-
array class method
-
HTML content forum posts PHP