if else statement - to echo class



I have a list of URL’s listed per line in file x.php:

Let’s say I have a link in my page with the following html code:


Well, if the x.php file is not too large, you can read it into an array. Then, you can use the “IN ARRAY” function of PHP to find out if the url is in the array of urls. This would just be one command. Assuming the url’s have been loaded into an array called $urls and the target one to match is in $target, something like this would work:

if (in_array($target, $urls)) {
echo “listed”;
ehco “notlisted”;
Fairly simple if you have the urls in an array!

If you have to do it by reading the text file, it would be easy, too. You can input one line at a time and trim the line and compare it. But, you would have to read the entire file each time. I would say it depends on how big a file you are talking about. If it is 10k or 100k, that is not much. So, a 50 character url, would mean about 2000 urls per 100k. Not much… So, why are you not doing this by way of a database? That would be faster than using a text file… Anyway, there you go… Good luck…