On 20 November 2003 17:39, Scott Fletcher wrote:

> How exactly does the 3rd parameter option work.  I tried this
> but it doesn't
> work, so I don't know how exactly does it work...  There isn't detail
> information on the php.net website...
> 
> --snip--
>    $XML_Start = (strpos($res_str,"<![CDATA[",1)+9);
>    $HTML_Start = (strpos($res_str,"<![CDATA[",2)+9);
>    $HTML_End = strpos($res_str,"]]>",1);
>    $XML_End = strpos($res_str,"]]>",2);
> --snip--

The manual is perfectly clear -- the third parameter is the offset within the string 
of where to start searching, not an occurrence number or any other way of counting.  
And the return value of strpos() is also an offset within the string.  So, assuming 
your CDATA segments are nested (which the above seems to imply), then:

>    $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+3);

If they're not nested, then the search order would need to be different (you need to 
look for substrings in the order in which they occur in the string as a whole) but the 
principle is exactly the same.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to