|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50702 strrpos offset argument doesn't work
Submitted: 2010-01-08 22:41 UTC Modified: 2010-01-09 09:47 UTC
From: samuel dot roze at gmail dot com Assigned:
Status: Not a bug Package: Unicode Engine related
PHP Version: 5.3.1 OS: Debian 5
Private report: No CVE-ID: None
 [2010-01-08 22:41 UTC] samuel dot roze at gmail dot com
The third sttrpos argument, $offset, doesn't act on data. With are without it, it is the same result.

Reproduce code:
$file_path = '/home/mon/fichier/LC_MESSAGES/message.po';

$last_bracket = strrpos($file_path, '/');

$last_bracket2 = strripos($file_path, '/', 20);


Expected result:
string(40) "/home/mon/fichier/LC_MESSAGES/message.po"

Actual result:
string(40) "/home/mon/fichier/LC_MESSAGES/message.po"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-09 03:28 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

You are searching for the last occurrence starting at position 20, which is still the last. You have to use -20 as offset. Please mind the strrpos documentation:

offset: May be specified to begin searching an arbitrary number of characters into the string. Negative values will stop searching at an arbitrary point prior to the end of the string.
 [2010-01-09 09:47 UTC] samuel dot roze at gmail dot com
Oh! I'm really sorry. I thought that $offset was the number of characters that are forgotten at the end of the string.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 20:01:30 2024 UTC