Ik heb bijv. een lijst met 300 cijfers in 3 text bestanden.
1tje heet NL, 1tje BE, en 1tje EN
Dan heb je deze code om ze te checken:
$cijfer heeft geen betekenis, maar dit is een voorbeeld. met $cijfer bedoel ik dus bijvoorbeeld je IP fzo. nl.txt ziet er zo uit:
en be.txt ziet er zo uit:
Dus als je code van 1 tot 100 is, ben je een nederlander, als je code van 101 tot 200 is, ben je een belg, en als je nummer van 201 tot 300 is, ben je een engelsman/vrouw
. Maar als je nummer nou 301 is, dan moet hij echoën: Je nummer is hier niet bekend. Hoe zorg ik hiervoor?
1tje heet NL, 1tje BE, en 1tje EN
Dan heb je deze code om ze te checken:
[COLOR= #0000BB]<?php
$nl[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"nl.txt"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$be[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"be.txt"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$en[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"en.txt"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$splitnl[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/split"]split[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$nl[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$splitbe[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/split"]split[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$be[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$spliten[/COLOR][COLOR= #007700]=[/COLOR] [URL="http://www.php.net/split"]split[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$en[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$splitnl[/COLOR] [COLOR= #007700]AS[/COLOR] [COLOR= #0000BB]$cijfersnl[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/list"]list[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$vannl[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$totnl[/COLOR][COLOR= #007700]) =[/COLOR] [URL="http://www.php.net/split"]split[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]" - "[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$cijfersnl[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](([/COLOR][COLOR= #0000BB]$cijfer[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]$vannl[/COLOR][COLOR= #007700]) && ([/COLOR][COLOR= #0000BB]$cijfer[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]$totnl[/COLOR][COLOR= #007700]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]U heeft een nederlands cijfer[/COLOR][COLOR= #007700];
}
}[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$splitbe[/COLOR] [COLOR= #007700]AS[/COLOR] [COLOR= #0000BB]$cijferbe[/COLOR][COLOR= #007700])
{[/COLOR]
[URL="http://www.php.net/list"]list[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$vanbe[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$totbe[/COLOR][COLOR= #007700]) =[/COLOR] [URL="http://www.php.net/split"]split[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]" - "[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$cijferbe[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](([/COLOR][COLOR= #0000BB]$cijfer[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]$vanbe[/COLOR][COLOR= #007700]) && ([/COLOR][COLOR= #0000BB]$cijfer[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]$totbe[/COLOR][COLOR= #007700]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]U heeft een belgisch cijfer[/COLOR][COLOR= #007700];
}
}[/COLOR]
?> $cijfer heeft geen betekenis, maar dit is een voorbeeld. met $cijfer bedoel ik dus bijvoorbeeld je IP fzo. nl.txt ziet er zo uit:
1 - 100 en be.txt ziet er zo uit:
101 - 200 Dus als je code van 1 tot 100 is, ben je een nederlander, als je code van 101 tot 200 is, ben je een belg, en als je nummer van 201 tot 300 is, ben je een engelsman/vrouw
. Maar als je nummer nou 301 is, dan moet hij echoën: Je nummer is hier niet bekend. Hoe zorg ik hiervoor?