Skip to content

explode ​

php
array explode(string $rozdzielenie, string $lancuch , [number $limit])

Returns an array of substrings obtained by splitting $lancuch wherever $rozdzielenie occurs. If $rozdzielenie is not found, the array contains one element: the entire $lancuch string.

If the third argument $limit is greater than zero, $lancuch is split into at most $limit elements, with the last element containing the remainder. If $limit is negative, the last -$limit elements are omitted from the result, which may produce an empty array. A $limit of 0 is treated as 1.

Example:

php
$lancuch = "This is a test";
$tablica = explode(" ",$lancuch);
print_r($tablica);

Result:

Array
(
[0] => This
[1] => is
[2] => a
[3] => test
)