Re: words in a string

From: Date: Sat, 17 Nov 2001 19:38:25 +0000
Subject: Re: words in a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75004@lists.php.net to get a copy of this message
> i want php to do an IF, when he founds a special word in a string (ex: > text_-_write_-_text ) .. i m not able to manage it .. <?php function doThis($x) { //something? $result = $x." phplover"; return $result; } $string = "Hi whats your name? Hi whats your name?"; $string_arr = explode(" ", $string); $newstring = "" for($i=0; $i<sizeof($string_arr); $i++) { if($string_arr[$i] == "Hi") { //Or ereg if the word only have to contain $string_arr[$i] = doThis($string_arr[$i]); } $newstring .= " ".$string_arr[$i]; } //Return Hi phplover whats your name? Hi phplover whats your name? echo $newstring; ?> Could you use this example? Regards, Johan

« previous php.general (#75004) next »