Introduction
Splitting a string helps you break a sentence or list into smaller parts so you can use each piece separately.
explode(string $delimiter, string $string, int $limit = PHP_INT_MAX): array
$parts = explode(",", "apple,banana,orange"); print_r($parts);
$words = explode(" ", "Hello world from PHP"); print_r($words);
$limited = explode(",", "one,two,three,four", 3); print_r($limited);
<?php // Example: split a list of colors $colors = "red,green,blue,yellow"; $colorArray = explode(",", $colors); foreach ($colorArray as $color) { echo "Color: $color\n"; } ?>
explode() do?'apple,banana,orange' by commas using explode()?$str = "one,two,three,four";
$result = explode(",", $str, 3);
print_r($result);$data = "red|green|blue"; $colors = explode($data, "|"); print_r($colors);
"name:age:city:country". You want to split it into exactly 3 parts where the last part contains everything after the second colon. Which explode() call achieves this?Pass the test and this pattern moves unknown