How to limit the elements created by explode()

Use the third parameter ($limit) of explode. The resulting array will have $limit Elements.

list($postcode, $city) = explode(" ", $string, 2);

Leave a Comment