Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce9b24f

Browse files
grantlovellGrahamCampbell
authored andcommitted
Add array_search to Support\Collection
Add the ability to perform array_search on Support\Collection.
1 parent 216d32a commit ce9b24f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/Illuminate/Support/Collection.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,18 @@ public function reverse()
376376
return new static(array_reverse($this->items));
377377
}
378378

379+
/**
380+
* Search the collection for a given item and returns the corresponding key if successful
381+
*
382+
* @param mixed $value
383+
* @param bool $strict
384+
* @return mixed
385+
*/
386+
public function search($value, $strict = false)
387+
{
388+
return array_search($value, $this->items, $strict);
389+
}
390+
379391
/**
380392
* Get and remove the first item from the collection.
381393
*

0 commit comments

Comments
 (0)