php-general | 2005051
Date: 05/12/05
- Next message: Jason Wong: "Re: [PHP] cURL functions"
- Previous message: Colin Ross: "Re: [PHP] Saving of buffers, from a security standpoint"
- In reply to: Merlin: "[PHP] str_replace on words?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Merlin wrote:
> Hi there,
>
> I am trying to strip some words from a sentence. I tried it with
> str_replace like described here:
> http://www.totallyphp.co.uk/code/find_and_replace_words_in_a_text_string_using_str_replace.htm
>
>
> Unfortunatelly it does not work the way I want, because if I want to
> replace the word "in" all passages containing the characters "in" are
> replaced. For example Singapore.
>
> Does anybody know how to do this on just words?
>
> Thank you for any hint,
>
> Merlin
>
$variable = 'I like to Sing in Singapore';
$variable = str_replace(' in ',' for ',$variable);
echo $varible;
Results should be:
I like to Sing for Singapore
James
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Jason Wong: "Re: [PHP] cURL functions"
- Previous message: Colin Ross: "Re: [PHP] Saving of buffers, from a security standpoint"
- In reply to: Merlin: "[PHP] str_replace on words?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

