php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22884 something strange with strchr
Submitted: 2003-03-25 17:49 UTC Modified: 2003-03-26 06:03 UTC
From: sebastien at mouzaia dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.1 OS: linux
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: sebastien at mouzaia dot com
New email:
PHP Version: OS:

 

 [2003-03-25 17:49 UTC] sebastien at mouzaia dot com
<?
print(phpversion().'<br>');
$string = "public_html/concepts/2L_vuda_dupont/wip/drawings";
$return = strrchr($string,'wip/');
print($return.'<br>'); // print wings WHY ???
print("<hr>");
$string = "public_html/concepts/2L_vuda_dupont/wip/drazings";
$return = strrchr($string,'wip/'); // print /wip/drazings(OK)
print($return.'<br>')
// tested on a 4.3.1 linux and on a 4.3.0 windows
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-25 18:06 UTC] moriyoshi@php.net
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

See http://www.php.net/manual/en/function.strrchr.php.

As described in the documentation, strrchr() doesn't work in the opposite way of strchr().

 [2003-03-26 02:52 UTC] sebastien at mouzaia dot com
Hello Moriyoshisan

I know the manual by hart :-)

I read in it:
This function returns the portion of haystack which starts at the last occurrence of needle and goes until the end of haystack. 

In my sample, it prints "wings" if I use the word "drawings" and what is expected, "/wip/drazings" if I use the word "drazings". This is not a bug ?

Thanks for your consideration.
 [2003-03-26 04:09 UTC] michael dot mauch at gmx dot de
Does your copy of the manual also have the sentence:

  If needle contains more than one character, the first is used.
 [2003-03-26 06:03 UTC] sebastien at mouzaia dot com
Yes :-( 
Sorry.
Thanks.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 13:01:33 2025 UTC