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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Mar 29 12:01:27 2024 UTC