Last active
August 5, 2017 21:06
-
-
Save fokosun/d5d03748d9f0134f3c0571cb07cea349 to your computer and use it in GitHub Desktop.
Stack Data structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$letters = []; | |
$word = "racecar"; | |
$rword = ""; | |
for($i=0; $i<strlen($word); $i++) { | |
array_push($letters, $word[$i]); | |
} | |
for($i=0; $i<strlen($word); $i++) { | |
$rword = $rword . array_pop($letters); | |
} | |
echo $rword === $word ? $word . " is a palendrome" : $word . " is not a palendrome"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment