Skip to content

Instantly share code, notes, and snippets.

@guanguans
Last active February 15, 2022 10:05
Show Gist options
  • Save guanguans/8611f008d555c39a08d22a8128c5fb39 to your computer and use it in GitHub Desktop.
Save guanguans/8611f008d555c39a08d22a8128c5fb39 to your computer and use it in GitHub Desktop.
#diffIds #verify
<?php
$diffIds = \Illuminate\Support\Str::of($inputStrIds = '1,2,5, ')
->trim()->trim(',')->trim()
->explode(',')
->filter(function ($value){
return filled($value);
})
->map(function ($item){
return trim($item);
})
->pipe(function (\Illuminate\Support\Collection $inputArrIds): \Illuminate\Support\Collection{
$dbIds = ['1', '2', '3'];
return $inputArrIds->diff($inputArrIds->intersect($dbIds));
})
->dd();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment