Skip to content

Instantly share code, notes, and snippets.

@antonioribeiro
Created April 14, 2019 14:32
Show Gist options
  • Save antonioribeiro/f69ea450df65280df3f859dbe0704bf1 to your computer and use it in GitHub Desktop.
Save antonioribeiro/f69ea450df65280df3f859dbe0704bf1 to your computer and use it in GitHub Desktop.

Revisions

  1. antonioribeiro created this gist Apr 14, 2019.
    10 changes: 10 additions & 0 deletions in.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    function in($needle, ...$haystack): bool
    {
    foreach ($haystack as $hay) {
    if ((is_array($hay) && in($needle, ...$hay)) || $needle == $hay) {
    return true;
    }
    }

    return false;
    }