Skip to content

Instantly share code, notes, and snippets.

@fokosun
Last active August 5, 2017 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fokosun/d5d03748d9f0134f3c0571cb07cea349 to your computer and use it in GitHub Desktop.
Save fokosun/d5d03748d9f0134f3c0571cb07cea349 to your computer and use it in GitHub Desktop.
Stack Data structure
$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