Created
January 15, 2019 05:41
-
-
Save ak4bento/22657c945e11790ae590ca1c88e478a4 to your computer and use it in GitHub Desktop.
implement containLetters function, given two words, returns true if all the letters of the first word are contained in the second.
This file contains hidden or 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
public function containLetters(string $firstWord, string $secondWord) | |
{ | |
$result = array(); | |
$inc = 0; | |
foreach (str_split($firstWord) as $firstSplit) | |
{ | |
foreach (str_split($secondWord) as $secondSplit) | |
{ | |
if (strtolower($firstSplit) == strtolower($secondSplit)) | |
{ | |
$result[$inc] = true; | |
} | |
else | |
{ | |
$result[$inc] = false; | |
} | |
} | |
$inc++; | |
} | |
foreach ($result as $final) | |
{ | |
if ($final == false) | |
{ | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment