The direct translation will be as follows:
switch(in_array($argv[$i], array('-V', '--version'))){
case true:
$displayVersion = TRUE; break;
}
However, you can also do something like this, which is clearer.
switch($argv[$i]){
case '-V':
case '--version':
$displayVersion = TRUE; break;
}
Depending on what you want to do, one liner may be more understandable, although it differs from the above code in that the variable will be set to false, if in_array($argv[$i], array('-V', '--version'))false. Given your variable name, I doubt it is bad.
$displayVersion = in_array($argv[$i], array('-V', '--version'));
source
share