Edit report at http://bugs.php.net/bug.php?id=53363&edit=1
ID: 53363
User updated by: apanatshka dot thedragoncouncil at gmail dot com
Reported by: apanatshka dot thedragoncouncil at gmail dot com
Summary: substr_count cannot find a \n when in a string with
\r\n
Status: Bogus
Type: Bug
Package: Strings related
Operating System: Windows XP SP 3
PHP Version: 5.3.1RC1
Block user comment: N
Private report: N
New Comment:
my bad, it's haystack first, then needle... I thought it was the other
way around
Previous Comments:
------------------------------------------------------------------------
[2010-11-20 12:16:13] [email protected]
Makes no sense substr_count("\n", "\r\n") returns 1. There is no "\r\n"
in "\n".
------------------------------------------------------------------------
[2010-11-20 11:03:03] apanatshka dot thedragoncouncil at gmail dot com
Description:
------------
---
>From manual page: http://www.php.net/function.substr-count#Description
---
substr_count cannot find a newline when in a string with a carriage
return and newline right after eachother
Test script:
---------------
<?php
echo substr_count("\n", "\n");
echo substr_count("\n", "\r\n");
echo substr_count('
', "\r\n");
//I've changed the following simple string in my script so it only holds
a newline character
echo substr_count('
', "\n");
//I've changed the following simple string in my script so it only holds
a newline character
echo substr_count("\n", '
');
echo substr_count("\n", '
');
echo substr_count('
', '
');
?>
Expected result:
----------------
1111111
Actual result:
--------------
1011101
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53363&edit=1