functiontake_a_walk(int$distance){if($distance%2==1){thrownewException("take an even number of steps or no return home! <br>");}$steps=[];$directions=['n','e','s','w'];for($i=1;$i<=$distance;$i+=2){$index=array_rand($directions);$steps[]=$directions[$index];$steps[]=$directions[($index+2)%4];}shuffle($steps);$steps=implode(', ',$steps).PHP_EOL;return$steps;}echo"Steps to take : ".take_a_walk(58);
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
PHP