#5 - PHP Explode Function
PHP explode function splits a string into an array. The split is based on a specific character. Here’s the syntax of this function.
explode(string $separator, string $string, int $limit = PHP_INT_MAX): array |
---|
Here the $separator is a specific character that determines the split points in the string.
Source
https://www.php.net/manual/en/function.explode.ph
xxxxxxxxxx
20
<?php
$fruits = "Apple,Mango,Strawberry,Orange,Pineapple";
$fruits_array = explode(",",$fruits);
/*
Output
Array
(
[0] => Apple
[1] => Mango
[2] => Strawberry
[3] => Orange
[4] => Pineapple
)
*/
print_r($fruits_array)
?>
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment