php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27921 strtok seems to return only the first chunk
Submitted: 2004-04-08 10:06 UTC Modified: 2004-04-08 11:03 UTC
From: scratch65536 at att dot net Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.4 OS: W2K
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: scratch65536 at att dot net
New email:
PHP Version: OS:

 

 [2004-04-08 10:06 UTC] scratch65536 at att dot net
Description:
------------
The strtok function seems to return a chunk only the first time it's called [ strtok( string, delim) ] Subsequent calls [ strtok( string ) ]  appear to return nothing.

I grepped for strtok in the changelist for 4.3.5, but saw nothing so I presume it's still a problem.

I tested this in 2 environments:

4.3.2 running as a module under Apache 1.3.27 under W2K
4.3.4 running as a module under Apache 2.0 under W2K

Reproduce code:
---------------
<?php
$s = '01:02:03' ;
$h = strtok( $s, ':' ) ;
$m = strtok( $s ) ;
$s = strtok( $s ) ;
echo "h=$h, m=$m, s=$s <br>" ;
?>

yields h=01, m=, s=

Expected result:
----------------
I expected to see h=01, m=02, s=03

Actual result:
--------------
h=01, m=, s=

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-08 11:03 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Pass the break again, not the string.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 12:01:30 2024 UTC