Forum Moderators: open

Message Too Old, No Replies

replacing words in sentence

         

wheelie34

4:14 pm on Mar 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have results in an array but would like to change certain words before printing the results.

$sql="select * from table where num='5'";
$result = mysql_query($sql, $dblink) or die("System down");
while ($newArray = mysql_fetch_array($result)){
$num = $newArray['num'];
$title = $newArray['title'];
$story = $newArray['story'];
{
str_replace('hello', 'hi', '$story');
}
$name = $newArray['name'];
}
print "$title, $story, $name";

$story is a sentence stored as TEXT in the database, am I going in the right direction? Still new to php but enjoying it, the above just prints as normal without changing the words.

Be gentle ;)

wheelie34

6:33 pm on Mar 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



incase anyone else needs this answering, I figured it out and it works perfect

$story = str_replace('hello', 'hi', $newArray['story']);