Edit report at https://bugs.php.net/bug.php?id=55180&edit=1

 ID:                 55180
 Updated by:         ahar...@php.net
 Reported by:        jonasvdegn at hotmail dot com
 Summary:            substr return is fail
-Status:             Open
+Status:             Bogus
 Type:               Bug
-Package:            Output Control
+Package:            Strings related
 Operating System:   Windows 7
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The third parameter for substr() is the number of characters to return, not the 
end position.


Previous Comments:
------------------------------------------------------------------------
[2011-07-11 07:52:45] jonasvdegn at hotmail dot com

Description:
------------
the substr(string,from,to) failed and return something i find strange, and 
never seen it before..

my version is also 5.3.5 but i chose 5.3.6 because the 5.3.5 is not there.

Test script:
---------------
$x=1;
while ($x<=strlen("hello"))
{
$xx=$x-1;
echo substr("hello",$xx,$x);
$x++;
}
echo "<br/>";

$x=1;
while ($x<=strlen("hello"))
{
$xx=$x-1;
echo $xx." ";
echo $x." ";
echo substr("hello",$xx,$x);
echo "<br/>";
$x++;
}

Expected result:
----------------
i expect a result saying:

hello
0 1 h
1 2 e
2 3 l
3 4 l
4 5 o

like in substr("hello",0,1) substr("hello",1,2) and continue like that.

Actual result:
--------------
the actual result is:

hellloloo
0 1 h
1 2 el
2 3 llo
3 4 lo
4 5 o

like substr("hello",1,2) is "el" how can that be?
and  substr("hello",2,3) is "llo" and how can that be too?


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55180&edit=1

Reply via email to