Check if it is possible to return to the starting position after moving in the given directions | Main method ; $n = 0 ; Count of North $s = 0 ; Count of South $e = 0 ; Count of East $w = 0 ; Count of West
< ? php $ st = " NNNWEWESSS " ; $ len = strlen ( $ st ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { if ( $ st [ $ i ] == ' N ' ) $ n += 1 ; if ( $ st [ $ i ] == ' S ' ) $ s += 1 ; if ( $ st [ $ i ] == ' W ' ) $ w += 1 ; if ( $ st [ $ i ] == ' E ' ) $ e += 1 ; } if ( $ n == $ s && $ w == $ e ) echo " YES STRNEWLINE " ; else echo " NO STRNEWLINE " ; ? >