note 67282 rejected from function.explode by bjori

From: Date: Tue, 06 Jun 2006 23:18:35 +0000
Subject: note 67282 rejected from function.explode by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-113399@lists.php.net to get a copy of this message
Note Submitter: grandhightrianglelover at gmail dot com ---- "If limit is set, the returned array will contain a maximum of limit elements with the last element containing the rest of string" Cool, but howabout if you just want up to (limit) elements without the rest of the string? <?php $ipString = "Hello\nWorld\n!\nThis\nIs\nA\nString"; $opArray = explode("\n", $ipString, -(count(explode("\n", $ipString))-3)); // returns opArray as: // [0] => Hello // [1] => World // [2] => ! ?> I didn't say it was neat, but it works :)

« previous php.notes (#113399) next »