php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #14714 String tokenizer appears to only work with tokens of size equal to one.
Submitted: 2001-12-27 02:35 UTC Modified: 2002-01-04 23:11 UTC
From: s371117 at student dot uq dot edu dot au Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.1.0 OS: linux redhat 7.0
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: s371117 at student dot uq dot edu dot au
New email:
PHP Version: OS:

 

 [2001-12-27 02:35 UTC] s371117 at student dot uq dot edu dot au
This code does not appear to work (it is almost a cut and paste from the manual with the token changed).  From experimentation I think it is beacause the token is two characters long.  I am not sure if this is a bug or a undocumented property of this function.

$string = "This is an example string";
$tok = strtok($string,"%s");
    while ($tok) {
    echo "Word=$tok<br>";
    $tok = strtok("%s");
}

I am sorry I can't be sure of the version of PHP on this server.  I only have ftp access.

Thanks for such a great product!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-04 19:03 UTC] elixer@php.net
Please create a php file with the following content, the version number of PHP will appear in the output:

<?php
    phpinfo();
?>

Let us know what version you are on.

Sean
 [2002-01-04 19:54 UTC] zak@php.net
strtok splits a string into tokens, each token delimited 
by any character from the token string.

Changing to documentation problem. Will fix shortly.

 [2002-01-04 23:11 UTC] s371117 at student dot uq dot edu dot au
Thanks for that.

I ended up using explode() to do what I wanted.

A user comment directed me to do this.

Thanks for all your help!
David
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 04:01:29 2024 UTC