Bedankt, ik plan namelijk een soort van verplaatsing van if te maken in sommige gevallen.
if functie
Tom schreef:Wat dan?Bedankt, ik plan namelijk een soort van verplaatsing van if te maken in sommige gevallen.
Tom schreef:verplaatsing van if?Bedankt, ik plan namelijk een soort van verplaatsing van if te maken in sommige gevallen.

(if is geen functie)
if Is wel een functie lol.
Tom schreef:Quote:if Is wel een functie lol.
Owh?
The if construct is one of the most important features of many languages
Waar staat dat dan?
Laat maar.
Als je nou $a en $b hebt en dit is die if:
$a && $b == "Lennard"
Nu check ie toch of $a true is en $b Lennard is
Hoe. kan je controlleren of $a en $b Lennard is zonder:
$a == "Lennard" && $b == "Lennard"
Is hier een shortcut voor ofzo?
$a && $b == "Lennard"
Nu check ie toch of $a true is en $b Lennard is
Hoe. kan je controlleren of $a en $b Lennard is zonder:
$a == "Lennard" && $b == "Lennard"
Is hier een shortcut voor ofzo?
Nope, daar is geen shortcut voor.
Dylanh schreef:Maak een eigen if functie die dat doet. Noem hem mif (multiple if) en geef de verwachte waarde als eerste parameter, en de vergelijkende waardes als opvolgende parameters. Doe vervolgens hetzelfde als wat je normaal zou doen.Als je nou $a en $b hebt en dit is die if:
$a && $b == "Lennard"
Nu check ie toch of $a true is en $b Lennard is
Hoe. kan je controlleren of $a en $b Lennard is zonder:
$a == "Lennard" && $b == "Lennard"
Is hier een shortcut voor ofzo?
Of ben niet zo lui en typ gewoon die 12 tekens meer

Dylanh schreef:Als je nou $a en $b hebt en dit is die if:
$a && $b == "Lennard"
Nu check ie toch of $a true is en $b Lennard is
Hoe. kan je controlleren of $a en $b Lennard is zonder:
$a == "Lennard" && $b == "Lennard"
Is hier een shortcut voor ofzo?
je zou het nog zo kunnen doen:
$a == $b && $a == Lennard
of zo:[COLOR= #0000BB]<?php $callback[/COLOR] [COLOR= #007700]= function([/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$value[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #DD0000]Lennard[/COLOR][COLOR= #007700]; };[/COLOR] [COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Lennard[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$b[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Lennard[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$map[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array_map"]array_map[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$callback[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$a[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$b[/COLOR][COLOR= #007700]));[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$map[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]] ==[/COLOR] true [COLOR= #007700]&&[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/array_unique"]array_unique[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$map[/COLOR][COLOR= #007700])) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]juah[/COLOR][COLOR= #007700]; }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]nope[/COLOR][COLOR= #007700]; }[/COLOR]

Ik heb al een funcite gemaakt, ik release het in andere topic