I made a text file named ben.txt
and there are some numbers line by line, for example 123456
so i want, whenever someone type !check 123456
so they should get message like Number Banned
I Made a code But it doesn't working
My Code
$been = file_get_contents(ben.txt);
$isbanned = false;
foreach ($been as $bb) {
if(strpos($message, "!sa $bb") ===0) $isbanned = true;
sendMessage($chatId, "<b>Number Banned!</b>");
return;
}
My Answer:
Here is a corrected version of your code:
php
$numbers = file('ben.txt', FILE_IGNORE_NEW_LINES);
$isBanned = false;
foreach ($numbers as $number) {
if (strpos($message, "!check $number") === 0) {
$isBanned = true;
break;
}
}
if ($isBanned) {
sendMessage($chatId, "Number Banned!");
}
In this code, we are reading the numbers from the `ben.txt` file line by line and checking if the user input matches any of the banned numbers. If a match is found, we set the `$isBanned` variable to true and send a message to the user indicating that the number is banned.
Rate this post
4 of 5 based on 1245 votesComments