For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > September 2006 > Re: how can I get some text from a file if I known the "FromText" and "









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: how can I get some text from a file if I known the "FromText" and "
SAN CAZIANO

2006-09-08, 6:57 pm

ok thankyou very much

"Juliette" <jrf_no_spam@jokeaday.net> wrote in message
news:45018752$0$56205$dbd4d001@news.wanadoo.nl...
> SAN CAZIANO wrote:
"ToText"[color=darkred]
>
>
> Something along the lines of the following (untested) should help
> (presumes that FromText and ToText will always exist in your data):
>
> // Get the position within the string of the end of $FromText
> $start = strpos($theData, $FromText) + strlen($FromText);
>
> // Get the length of the string to take out, by getting the position of
> the beginning of $ToText and substracting the $start position
> $offset = strpos($theData, $ToText, $start) - $start;
>
> // Get the data
> $text = substr($theData, $start, $offset);
>
> Have a look at the manual for more information on the functions I used.



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com