Skip to content

Instantly share code, notes, and snippets.

@crossmaya
Last active May 8, 2021 01:59
Show Gist options
  • Save crossmaya/5319554 to your computer and use it in GitHub Desktop.
Save crossmaya/5319554 to your computer and use it in GitHub Desktop.
php basic helps
<?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