I have urls coming in from an RSS feed. I need to change them to add one thing. index.php should be index2.php. What is the best way to do this?
please elucidate your request. are you trying to change index.php to index2.php? I'm not advanced as a php developer, that said, is masking an option or is that something totally different?
Omnistar Etools offers Web Software Solutions for Businesses
echo preg_replace('~(?<=/)index.php~', 'index2.php', 'http://www.yourserver.com/index.php?foo=bar'); #http://www.yourserver.com/index2.php?foo=bar
Try using the substr function to split up the string into usable segments.
Hope this helps. Here is the link to this function: www.php.net/substr.PHP Code:
$string = 'index.php';
$bit_to_add = '2';
$newstring = substr($string, 0, -4).$bit_to_add.substr($string, -4);