Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2010
    Posts
    38
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Changing Dynamically Words in Text

    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>
    Last edited by young_coder; 06-21-2010 at 07:13 PM. Reason: I did not described problem properly

  • #2
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    PHP Code:
    <?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?

  • #3
    New Coder
    Join Date
    Feb 2010
    Posts
    38
    Thanks
    14
    Thanked 0 Times in 0 Posts
    Sorry, maybe I did not described problem enough. Text with ###KEYWORD### is also dynamic content. It is displayed RSS feed.
    Thank you

  • #4
    New Coder
    Join Date
    Jun 2010
    Location
    The Netherlands
    Posts
    53
    Thanks
    0
    Thanked 6 Times in 6 Posts
    before you echo your feed, store the feed in a variable.

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

  • #5
    New Coder
    Join Date
    Feb 2010
    Posts
    38
    Thanks
    14
    Thanked 0 Times in 0 Posts
    I have tried to do str_replace on wrong place…
    Now it is OK... working...
    Thank you to everyone


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •