#26352 [Opn]: strpos() webpage missing an example for the use of offset attriubte
| From: | scott at abcoa dot com | Date: | Fri, 21 Nov 2003 17:11:57 +0000 |
| Subject: | #26352 [Opn]: strpos() webpage missing an example for the use of offset attriubte | ||
| References: | 1 | Groups: | php.mirrors |
| Request: | Send a blank email to php-mirrors+get-22140@lists.php.net to get a copy of this message | ||
ID: 26352
User updated by: scott at abcoa dot com
Reported By: scott at abcoa dot com
Status: Open
Bug Type: Website problem
PHP Version: Irrelevant
New Comment:
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'.
Previous Comments:
------------------------------------------------------------------------
[2003-11-21 11:47:24] 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!!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26352&edit=1