Last active
May 8, 2021 01:59
-
-
Save crossmaya/5319554 to your computer and use it in GitHub Desktop.
php basic helps
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 helper **/ | |
| function array_except($array, $key) | |
| { | |
| return array_diff_key($array, array_flip((array) $key)); | |
| } | |
| /* String Helper */ | |
| function start_with($haystack, $needle) | |
| { | |
| return strpos($haystack, $needle) === 0; | |
| } | |
| function ends_with($haystack, $needle) | |
| { | |
| return $needle == substr($haystack, strlen($haystack) - strlen($needle)); | |
| } | |
| /* Common Helper */ | |
| function with($object) | |
| { | |
| return $object; | |
| } | |
| function value($value) | |
| { | |
| return $object instanceof Closure ? $value() : $value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment