At 13:48 18/01/01 +0000, jalist wrote:
>I'm trying to grab a string from within a string based on a matching word or
>phrase. Example...
>
>$string = "This is a string I need to grab the middle out of"
>$query_word = "need"
>
>I need to get x amount of characters either side of $query_word, so the
>result string would be like...
>
>"string I need to grab the"
>
>And I need the result string to be full words, not like..."ing I need to
>grab th"
>
>I've half managed to do it using strpos and substr but the code is really
>messy and I'm getting half-formed words back. Anyone got any suggestion on
>how to accomplish this?
>
>Thanks very much in advance.

I'd suggest using regular expressions (ereg, or preg_match). It's a little 
too early in the morning on a weekend for me to come up with the best 
example of what would work, sorry :)

Angus.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to