Als het er niet tussen staat

Gestart doorBartv1 reacties60 weergaven

2 berichten · pagina 1 van 1

Bartv

Lid · Topicstarter

Berichten
4.451
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
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:

[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 emo. Maar als je nummer nou 301 is, dan moet hij echoën: Je nummer is hier niet bekend. Hoe zorg ik hiervoor?
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
if($cijfer > 300) {
echo Je nummer is hier niet bekend.;
}
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren