young_coder Posted June 21, 2010 Share Posted June 21, 2010 Dear all, I need to change dynamically ###KEYWORD### in text with same word or phrase like in echo ($keyword); Text with ###KEYWORD### is 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> Link to comment https://forums.phpfreaks.com/topic/205448-changing-dynamically-words-in-text/ Share on other sites More sharing options...
kenrbnsn Posted June 21, 2010 Share Posted June 21, 2010 Use the str_replace function: <?php $str = 'This is text, and ###KEYWORD###'; $newstr = str_replace('###KEYWORD###',$keyword); echo $newstr; ?> Ken Link to comment https://forums.phpfreaks.com/topic/205448-changing-dynamically-words-in-text/#findComment-1075132 Share on other sites More sharing options...
gwolgamott Posted June 21, 2010 Share Posted June 21, 2010 str_replace()... EDIT.... Oops kenrbnsn beat me to it... sorry for being repetitive... hit post accidentally anyways when it gave me the warning msg. Link to comment https://forums.phpfreaks.com/topic/205448-changing-dynamically-words-in-text/#findComment-1075134 Share on other sites More sharing options...
young_coder Posted June 21, 2010 Author Share Posted June 21, 2010 I have tried to do str_replace on wrong place… Now it is OK... working... Thank you to everyone Link to comment https://forums.phpfreaks.com/topic/205448-changing-dynamically-words-in-text/#findComment-1075186 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.