#34477 [Opn->Bgs]: strtok() treats repeat of characters as single occurance
| From: | derick@php.net | Date: | Mon, 12 Sep 2005 08:37:43 +0000 |
| Subject: | #34477 [Opn->Bgs]: strtok() treats repeat of characters as single occurance | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-84912@lists.php.net to get a copy of this message | ||
ID: 34477
Updated by: derick@php.net
Reported By: black at scene-si dot org
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: linux deb
PHP Version: 4.4.0
New Comment:
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
This is modelled after unix' strtok:
http://www.opengroup.org/onlinepubs/007908799/xsh/strtok.html
Previous Comments:
------------------------------------------------------------------------
[2005-09-12 10:16:22] black at scene-si dot org
Description:
------------
strtok() ignores repeats of "arg2" ie. needle, and treats it as a
single occurance, skipping all repetitions
Reproduce code:
---------------
$query = "wtf ? omg ? wtf ???, ?";
$arguments = array(1,2,3,4,5,6);
var_dump($query);
$sql = strtok($query,"?");
var_dump($sql);
$retval = "";
while ($sql!==false) {
$wasempty = empty($arguments);
$val = array_shift($arguments);
$retval .= $sql;
if (!is_null($val) || !$wasempty) {
$retval .= "'".$this->escape($val).'\'';
}
$sql = strtok("?");
var_dump($sql);
}
echo $retval;
Expected result:
----------------
string(22) "wtf ? omg ? wtf ???, ?"
string(4) "wtf "
string(5) " omg "
string(5) " wtf "
string(0) ""
string(0) ""
string(2) ", "
bool(false)
wtf '1' omg '2' wtf '3''4''5', '6'
Actual result:
--------------
string(22) "wtf ? omg ? wtf ???, ?"
string(4) "wtf "
string(5) " omg "
string(5) " wtf "
string(2) ", "
bool(false)
wtf '1' omg '2' wtf '3', '4'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34477&edit=1