Bug #53363 [Opn->Bgs]: substr_count cannot find a \n when in a string with \r\n

From: Date: Sat, 20 Nov 2010 11:16:15 +0000
Subject: Bug #53363 [Opn->Bgs]: substr_count cannot find a \n when in a string with \r\n
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-156244@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53363&edit=1 ID: 53363 Updated by: felipe@php.net Reported by: apanatshka dot thedragoncouncil at gmail dot com Summary: substr_count cannot find a \n when in a string with \r\n -Status: Open +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: Makes no sense substr_count("\n", "\r\n") returns 1. There is no "\r\n" in "\n". Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#156244) next »