dunnsearch Posted August 19, 2009 Share Posted August 19, 2009 Right I have the following: if (in_array($URL1, $URL2, $URL3)) {} else { How would i reaplace those URL's with URL4? Thanks. I need this badly Quote Link to comment https://forums.phpfreaks.com/topic/170937-help-with-blocking-url/ Share on other sites More sharing options...
pudge1 Posted August 19, 2009 Share Posted August 19, 2009 <?php str_replace($url1,$url4,$text); str_replace($url2,$url4,$text); ... ?> Is that what you mean? Quote Link to comment https://forums.phpfreaks.com/topic/170937-help-with-blocking-url/#findComment-901551 Share on other sites More sharing options...
corbin Posted August 19, 2009 Share Posted August 19, 2009 Huh? I think you should read the manual page on in_array. Quote Link to comment https://forums.phpfreaks.com/topic/170937-help-with-blocking-url/#findComment-901552 Share on other sites More sharing options...
dunnsearch Posted August 19, 2009 Author Share Posted August 19, 2009 Ok here is is: $torrenthost = $torrenthost[0]; // torrent host name $torrenthostlink = $torrenthostlink[0]; // torrent download link $torrentnameinhost = $torrentnameinhost[0]; // torrent name in host $torrentupdateinhost = $torrentupdateinhost[0]; // torrent update time $blockedsites = array("test.com", "www.anothertest.com", "www.example.com", "url.com", "www.phpfreaksexample.com"); if (in_array($torrenthost, $torrenthostlink, $blockedsites)) {} else { How can i replace them with another url if theye should up on page What to put in? if (in_array($torrenthost, $torrenthostlink, $blockedsites)) {} else { ??? Quote Link to comment https://forums.phpfreaks.com/topic/170937-help-with-blocking-url/#findComment-901894 Share on other sites More sharing options...
mikesta707 Posted August 19, 2009 Share Posted August 19, 2009 you aren't using the in_array() function correctly... at all... Quote Link to comment https://forums.phpfreaks.com/topic/170937-help-with-blocking-url/#findComment-901899 Share on other sites More sharing options...
dunnsearch Posted August 19, 2009 Author Share Posted August 19, 2009 so how do i get it to replace the blocked urls? Quote Link to comment https://forums.phpfreaks.com/topic/170937-help-with-blocking-url/#findComment-901931 Share on other sites More sharing options...
mikesta707 Posted August 19, 2009 Share Posted August 19, 2009 what do you mean by replace the blocked URL? replace them with what? Quote Link to comment https://forums.phpfreaks.com/topic/170937-help-with-blocking-url/#findComment-901933 Share on other sites More sharing options...
dunnsearch Posted August 19, 2009 Author Share Posted August 19, 2009 Just to block it from appearing. You see. I have created a meta search engine but it also picks up adverts from the search engines it searches. I need to remove these links from the files list. So just to block it from appearing on my site will do Quote Link to comment https://forums.phpfreaks.com/topic/170937-help-with-blocking-url/#findComment-901953 Share on other sites More sharing options...
Monadoxin Posted August 19, 2009 Share Posted August 19, 2009 If the page contents is inside a string what you could do is create an array with all of the bad urls that you do not want in your page, then do a loop through that array. In the loop see if the page contains the 'bad site' and replace it with whatever else you want: <?php $sPageContent = "blah blah blah, look at this website: http://badurl2.com!"; $aBadSites = array("http://badurl1.com", "http://badurl2.com", "http://badurl3.com", etc); foreach($aBadSites as $sBadSite) { $sPageContent = str_replace($sBadSite, "http://goodsite.com", $sPageContent); } print $sPageContent; ?> The output would be this: blah blah blah, look at this website: http://goodsite.com! Quote Link to comment https://forums.phpfreaks.com/topic/170937-help-with-blocking-url/#findComment-901955 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.