Answer the question
In order to leave comments, you need to log in
How to implement whole word search in txt via PHP?
And so, there is a text file. domains.txt
It contains domains that are allowed to install the script, but not the essence.
Now I'm doing auto-activation.
In general, how to make it search in this txt if there is a domain, for example, vk.com.
I tried using strpos, but it did not work out very well, it looked for every letter :(
if there is, then the error is 'This domain is activated!';
if not, then 'The domain was successfully activated!';
Answer the question
In order to leave comments, you need to log in
Andrew : Thank you!
Did it like this:
$txt = file_get_contents("domains.txt");
$domain = $_GET['domain'];
$explode = explode(":", $txt);
if (in_array($domain, $explode)) {
echo "Данный домен активирован!";
}
$text = 'test.ru
vk.com
redis.org
';
preg_match('/vk\.com/mi', $text, $matches);
if (count($matches) > 0) {
echo "true"; }
Or so at all
<?php
$domain='vk.com';
$txt=file_get_contents("domains.txt");
if(stristr($txt, $domain))
echo 'Домен активирован';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question