I would prefer laserlight's solution. It is more simple.
... but here is another way
<?php
// all allowed actions
$allowed = array( 'north', 'n', 'North', 'N' );
foreach( $allowed AS $option ) {
if ( $action == $option ) {
// perform action
echo $action;
}
}
if is enough that first character is 'N' or 'n', regardless what the other characters are
(for example: n, N, nanny, Nipper, will all trigger action)
This useful if we expect answer: yes, Yes, YES, y, Y and no, No, NO, n, N
then we can use this
<?php
// test the first char of $action in lower case
if ( strtolower( $action{0} ) == 'n' ){
//perform 'NO' action
echo $action;
}
if ( strtolower( $action{0} ) == 'y' ){
//perform 'YES' action
echo $action;
}
?>