php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3003 split() limit not working correctly
Submitted: 1999-12-19 00:34 UTC Modified: 2000-05-22 14:53 UTC
From: norman at email dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.12 OS: BSD/OS 3.1 i386
Private report: No CVE-ID: None
 [1999-12-19 00:34 UTC] norman at email dot com
split() seems to be truncating data when using a limit
argument, eg.

<?php
$x = split("-", "a-b-c-d", 2);
print $x[1];
?>

this should produce "b", but it produces "b-c-d" instead.

this is the installation of PHP 3.0.12 used on www.iserver.com's accounts.

i believe bug #1570 is the same problem.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-22 14:53 UTC] hholzgra at cvs dot php dot net
no #1570 was the other way round

the last array elemnt returned by split with limit
is to contain the rest of the input string,
only the first (limit-1) elements contain 'true splits'

(the documentation is not clear in this case, i'll
fix that later)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Jun 18 21:00:01 2026 UTC