Last active
November 20, 2017 11:02
-
-
Save anthonybudd/9c32cc1698cb8b1d6144944a402e3c1c to your computer and use it in GitHub Desktop.
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
| <?php | |
| $array = ['quick', 'fox']; | |
| $string = 'the quick brown fox jumps over the lazy dog'; | |
| if(in_array(1,array_map(function($e)use($string){return(strpos($string, $e)!== FALSE)?1:0;},$array))){ | |
| echo "The string contains an element in the array."; | |
| } |
PHP doesn't have arrow functions, right? Or did I miss anything?
Since when did PHP have arrow functions lmao
@JoelLarson https://wiki.php.net/rfc/arrow_functions php doesn't have arrow functions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can remove the single quotes around the numbers to reduce some characters
You can also guarantee that
strpos() !== falsewill always return a boolean.Also PHP now has arrow functions: