papaface Posted January 14, 2007 Share Posted January 14, 2007 Hello,I was wondering if someone can tell me if this is possible.I am currently writing a link exchange script. Is it possible to have the script detect if the link is/is not present on the page it is supposed to be?regards Link to comment https://forums.phpfreaks.com/topic/34181-find-a-link-link-exchange-script/ Share on other sites More sharing options...
papaface Posted January 15, 2007 Author Share Posted January 15, 2007 Anyone? Link to comment https://forums.phpfreaks.com/topic/34181-find-a-link-link-exchange-script/#findComment-160840 Share on other sites More sharing options...
trq Posted January 15, 2007 Share Posted January 15, 2007 You could easily enough read the page using [url=http://php.net/file_get_contents]file_get_contents[/url] then search it for the link. Link to comment https://forums.phpfreaks.com/topic/34181-find-a-link-link-exchange-script/#findComment-160842 Share on other sites More sharing options...
papaface Posted January 16, 2007 Author Share Posted January 16, 2007 Ive tried to go this but I cant get it to work.The code i have is:reciprocalcheck.php:[code]<?php$checkurl = file("http://localhost/ee/admin/reciprocaltest.html");$check = '<a href="http://www.domain.com/enter.php?refer=1">';if(in_array($check, $checkurl)) { echo "link found"; }else { echo "link NOT found"; }?>[/code]reciprocaltest.html:[code]<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><a href="http://www.domain.com/enter.php?refer=1">Your Site Name Here</a></body></html>[/code]Why isnt this working? Link to comment https://forums.phpfreaks.com/topic/34181-find-a-link-link-exchange-script/#findComment-162229 Share on other sites More sharing options...
papaface Posted January 16, 2007 Author Share Posted January 16, 2007 Any help please? ;D Link to comment https://forums.phpfreaks.com/topic/34181-find-a-link-link-exchange-script/#findComment-162261 Share on other sites More sharing options...
scott212 Posted January 16, 2007 Share Posted January 16, 2007 I would do a foreach loop over the array (or while or for). That way you have a value to work with. Chances are it's not finding it due to the file's line returns on each line. If you could trim(value) before comparing the current line to what you want, I think you'd find it. Link to comment https://forums.phpfreaks.com/topic/34181-find-a-link-link-exchange-script/#findComment-162273 Share on other sites More sharing options...
papaface Posted January 16, 2007 Author Share Posted January 16, 2007 I have tried:[code]<?php$checkurl = file("http://localhost/ee/admin/reciprocaltest.html");$checkurl = array_map("trim", $checkurl);$check = '<a href="http://www.domain.com/enter.php?refer=1">';if(in_array($check, $checkurl)) { echo "link found"; }else { echo "link NOT found"; }?>[/code] But it still doesnt work. Link to comment https://forums.phpfreaks.com/topic/34181-find-a-link-link-exchange-script/#findComment-162279 Share on other sites More sharing options...
papaface Posted January 16, 2007 Author Share Posted January 16, 2007 Sorry for bumping, but advice/help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/34181-find-a-link-link-exchange-script/#findComment-162345 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.