Jump to content

Find a link - link exchange script


papaface

Recommended Posts

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?
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.
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.