|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-04-20 23:45 UTC] proton@php.net
Description: ------------ http://www.php.net/explode Manual gives an example of limit-parameter used in explode(). Example 2 shows negative limit-value example and it seems not working like expected. Test-code at web: http://mikrolahti.fi/explode.php Reproduce code: --------------- <?php $str = 'one|two|three|four'; // positive limit print_r(explode('|', $str, 2)); // negative limit print_r(explode('|', $str, -1)); ?> Expected result: ---------------- Array ( [0] => one [1] => two|three|four ) Array ( [0] => one [1] => two [2] => three ) Actual result: -------------- Array ( [0] => one [1] => two|three|four ) Array ( [0] => one [1] => two [2] => three [3] => four ) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 08:00:01 2025 UTC |
It does the same on current PHP-version also. nandus% uname -a FreeBSD nandus.mikrolahti.fi 5.4-STABLE FreeBSD 5.4-STABLE #0: Tue Apr 19 23:27:27 EEST 2005 root@nandus.mikrolahti.fi:/usr/obj/usr/src/sys/NANDUS i386 nandus% cat explode.php <?php $str = 'one|two|three|four'; // positive limit print_r(explode('|', $str, 2)); // negative limit print_r(explode('|', $str, -1)); ?> nandus% php explode.php Content-type: text/html X-Powered-By: PHP/5.0.4 Array ( [0] => one [1] => two|three|four ) Array ( [0] => one [1] => two [2] => three [3] => four )