Created
October 27, 2017 17:11
-
-
Save coreysan/7a4baa0521e4f43903f2179804500b6a to your computer and use it in GitHub Desktop.
PHP Junior Test: isContained
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
<?php | |
/** | |
* Make the function pass all the tests! | |
* | |
* Your function should return true if and only if all tokens | |
* can be found in the long string given. | |
* | |
* Run this file on the command line using: | |
* $ php isContained.php | |
* | |
* Or use a repl like https://repl.it/languages/php | |
*/ | |
/** | |
* description ? | |
* | |
* @param ? | |
* @param ? | |
* | |
* @return ? | |
*/ | |
function isContained(string $long_string, array $tokens) | |
{ | |
// determine whether EVERY token can be found within $long_string | |
return -1; | |
} | |
// In these cases, the tokens are found | |
echo ((true === isContained("abcdefghijklm", [])) ? "Passes" : "Fails")."\n\n"; | |
echo ((true === isContained("abcdefghijklm", ['a'])) ? "Passes" : "Fails")."\n\n"; | |
echo ((true === isContained("abcdefghijklm", ['abc', 'def'])) ? "Passes" : "Fails")."\n\n"; | |
echo ((true === isContained("abcdefghijklm", ['a', 'f'])) ? "Passes" : "Fails")."\n\n"; | |
echo ((true === isContained("abcdefghijklm", ['abcdefghijklm'])) ? "Passes" : "Fails")."\n\n"; | |
// tokens are NOT found | |
echo ((false === isContained("abcdefghijklm", ['A'])) ? "Passes" : "Fails")."\n\n"; | |
echo ((false === isContained("abcdefghijklm", ['ba'])) ? "Passes" : "Fails")."\n\n"; | |
echo ((false === isContained("abcdefghijklm", ['a', 'b', 'c', 'x'])) ? "Passes" : "Fails")."\n\n"; | |
echo ((false === isContained("abcdefghijklm", ['abcdefghijklmx'])) ? "Passes" : "Fails")."\n\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment