Jump to content

str_replace help


mnybud

Recommended Posts

I am trying to learn PHP and am a novice so please excuse the stupid question but I have researched and attempted to find a solution for this and cant. Hoping someone can help me.

 

I have the following code I am using within a Wordpress template...

 

<?php if (function_exists('simple_feed_list')) : ?>
<?php
$title = get_the_title();
str_replace("+", " ", $title);
simple_feed_list('http://www.amazon.com/rss/tag/'. str_replace(" ", "+", $title) .'/new/ref=tag_tdp_rss_new_man?tag=search-20','limit=5&desc=yes&nofollow=yes&more=no'); ?>
<?php endif; ?>

 

I am trying to make it produce a RSS feed url from amazon that looks like this:

http://www.amazon.com/rss/tag/ipod ibuds/new/ref=tag_tdp_rss_new_man?tag=search-20

note the space between ipod and buds, that is what I am trying to accomplish.

Right now the space is being changed I think to a + sign which breaks the feed if the search term is more than one word.

 

Can anyone help me fix this? I have tried removing the string replace part, etc with no luck :(

Link to comment
Share on other sites

I have also tried this with no luck... anyone have any ideas?

 

<?php if (function_exists('simple_feed_list')) : ?>
<?php
$title = get_the_title();
simple_feed_list('http://www.amazon.com/rss/tag/'. str_replace("", "", $title) .'/new/ref=tag_tdp_rss_new_man?tag=search-20','limit=5&desc=yes&nofollow=yes&more=no'); ?>
<?php endif; ?>

Link to comment
Share on other sites

<?php if (function_exists('simple_feed_list')) : ?>
<?php
$title = get_the_title();
$url = "http://www.amazon.com/rss/tag/$title/new/ref=tag_tdp_rss_new_man?tag=search-20";
$url = urlencode($url);
simple_feed_list($url,'limit=5&desc=yes&nofollow=yes&more=no'); ?>
<?php endif; ?>

url's dont have spaces in them

Link to comment
Share on other sites

thanks but that still is not working. It works if the page title is one word but not if it is more than one.

 

and in this case the urls do include a space....example.

 

max results

http://www.amazon.com/rss/tag/ipod accessories/new/ref=tag_tdp_rss_new_man?tag=biblesforthew-20

 

limited results

http://www.amazon.com/rss/tag/ipodaccessories/new/ref=tag_tdp_rss_new_man?tag=biblesforthew-20

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.