← All built-ins / explode()

explode()

explode(string $haystack, string $needle): mixed

Parameters

NameTypeDescription
$separatorstringdelimiter (cannot be empty)
$sstringstring to split

Return value

Array of the pieces between separators.

Example

$p = explode(",", "a,b,c");
echo count($p), " ", $p[1], "
";
echo explode("/", "2024/03/15")[2], "
";
3 b
15

See also

implode()preg_split()str_split()