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? 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. 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. 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
Archived
This topic is now archived and is closed to further replies.