Skip to content

Instantly share code, notes, and snippets.

@sasin91
Created August 13, 2020 11:52
Show Gist options
  • Save sasin91/265d37ada608eab37e967d909fb4c914 to your computer and use it in GitHub Desktop.
Save sasin91/265d37ada608eab37e967d909fb4c914 to your computer and use it in GitHub Desktop.
Str::compare
Str::macro('compare', function (string $value, string $to, string $delimiter = ' ') {
return collect(explode($delimiter, $value))
->zip(explode($delimiter, $to))
->filter(function ($pair) {
return $pair->first() !== $pair->last();
})
->collapse();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment