nate_kig Posted January 14, 2011 Share Posted January 14, 2011 Hey guys I have been trying to modify a wordpress plugin (Wordpress.com Stats) so that all links on the dashboard are changed from this: http://blogurl.com/wp-admin/index.php?page=stats&view=referrers&numdays=7&blog=18555781 to this: http://blogurl.com/wp-admin/admin.php?page=stats&view=referrers&numdays=7&blog=18555781 I cannot find the part that chooses the link urls so I was hoping I could make a preg_replace statement that would replace all instances of "index.php" with "admin.php" that get generated. Is this possible to do? Quote Link to comment https://forums.phpfreaks.com/topic/224390-change-all-instances-of-a-url-inside-of-a-php-script-with-preg_replace/ Share on other sites More sharing options...
thcx Posted January 14, 2011 Share Posted January 14, 2011 $url = preg_replace('%/index\.php\?%', '/admin.php?', $url); This changes one URL or string. If you want to do that over a whole file, you'll need to put it in a loop. Quote Link to comment https://forums.phpfreaks.com/topic/224390-change-all-instances-of-a-url-inside-of-a-php-script-with-preg_replace/#findComment-1159480 Share on other sites More sharing options...
requinix Posted January 15, 2011 Share Posted January 15, 2011 This changes one URL or string. If you want to do that over a whole file, you'll need to put it in a loop. Actually it will change every instance in $url, not just the first one. Quote Link to comment https://forums.phpfreaks.com/topic/224390-change-all-instances-of-a-url-inside-of-a-php-script-with-preg_replace/#findComment-1159580 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.