php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #26352 strpos() webpage missing an example for the use of offset attriubte
Submitted: 2003-11-21 11:47 UTC Modified: 2004-01-01 17:49 UTC
From: scott at abcoa dot com Assigned: kennyt (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2003-11-21 11:47 UTC] scott at abcoa dot com
Description:
------------
Read the strpos() function at http://us3.php.net/manual/en/function.strpos.php and had some trouble with it for a while, it took me a while to better understand it because I never use this function before.  There are two problem here.  

Problem #1: The word 'offset' is a bad choice of word because the definition of it can be anything to what anyone's interpretation of the definition.  Like mine, I assumed that offset meant to cancel each other out but when playing around with the script, I then knew that is not what it meant so I had no idea of what it meant.  This problem can be overcome by the Problem #2.

Problem #2: There is no example script of a strpos() with the use of offset attribute.  So, how about updating the webpage to include the example.  That would help to reduce the confusion and struggling in the long run.  An example of it would be like this but don't take my word for it and you can use a simplier example

--
   $res_str = "blah blah blah blah";
   $XML_Start = (strpos($res_str,"<![CDATA[")+9);
   $HTML_Start = (strpos($res_str,"<![CDATA[",$XML_Start)+9);
   $HTML_End = strpos($res_str,"]]>",$HTML_Start);
   $XML_End = strpos($res_str,"]]>",$HTML_End);
--snip--

Thanks!!


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-21 12:11 UTC] scott at abcoa dot com
Boy!  Bad example I put down.

--snip--
   $HTML_End = strpos($res_str,"]]>",$HTML_Start);
   $XML_End = strpos($res_str,"]]>",$HTML_End);
--snip--

Would cause the variable $HTML_End and $XML_End to have the save value.  So, an better example would be 

--snip--
   $HTML_End = strpos($res_str,"]]>",$HTML_Start);
   $XML_End = strpos($res_str,"]]>",($HTML_End+1));
--snip--

But you get the drift about the need for a better example and a better example to clarify the understanding of hte word, 'offset'.
 [2003-11-21 12:30 UTC] goba@php.net
This is a docbug.
 [2004-01-01 17:49 UTC] kennyt@php.net
Added an example.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 15:00:02 2025 UTC