...

View Full Version : Changing Dynamically Words in Text



young_coder
06-21-2010, 06:42 PM
Dear all,
I need to change dynamically ###KEYWORD### in text with same word or phrase like in echo ($keyword);

EDIT:Sorry, maybe I did not described problem enough. Text with ###KEYWORD### is also dynamic content. It is displayed RSS feed.

Can it be done..?
Thank you

<?php
session_start();
$_SESSION['raw_query'] = $_GET['q'];
$_SESSION['ad_group'] = str_replace("-", " ", $_GET['q']);

$keyword = $_SESSION["ad_group"];
echo ($keyword);
?>

<p>This is text, and ###KEYWORD### is word I wish to replace with same thing that is in "echo ($keyword);".</p>

met
06-21-2010, 07:01 PM
<?php
session_start();
$_SESSION['raw_query'] = $_GET['q'];
$_SESSION['ad_group'] = str_replace("-", " ", $_GET['q']);

$keyword = $_SESSION["ad_group"];
echo ($keyword);
?>

<p>This is text, and <?php echo $keyword; ?> is word I wish to replace with same thing that is in "echo ($keyword);".</p>


are you even trying?

young_coder
06-21-2010, 07:08 PM
Sorry, maybe I did not described problem enough. Text with ###KEYWORD### is also dynamic content. It is displayed RSS feed.
Thank you

Candan
06-21-2010, 07:15 PM
before you echo your feed, store the feed in a variable.



$feed = "Your RSS feed here. ###KEYWORD###";
$keyword = "Test Keyword";
$feed = str_replace("###KEYWORD###", $keyword, $feed);
echo $feed;

young_coder
06-21-2010, 08:34 PM
I have tried to do str_replace on wrong place…
Now it is OK... working...
Thank you to everyone :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum