note 67282 added to function.explode

From: Date: Tue, 06 Jun 2006 22:19:34 +0000
Subject: note 67282 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-113396@lists.php.net to get a copy of this message
"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 :) ---- Server IP: 84.18.202.180 Probable Submitter: 81.179.30.97 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- http://master.php.net/note/edit/67282 Del: integrated -- http://master.php.net/note/delete/67282/integrated Del: useless -- http://master.php.net/note/delete/67282/useless Del: bad code -- http://master.php.net/note/delete/67282/bad+code Del: spam -- http://master.php.net/note/delete/67282/spam Del: non-english -- http://master.php.net/note/delete/67282/non-english Del: in docs -- http://master.php.net/note/delete/67282/in+docs Del: other reasons-- http://master.php.net/note/delete/67282 Reject -- http://master.php.net/note/reject/67282 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#113396) next »