This repository was archived by the owner on Feb 1, 2020. It is now read-only.
This repository was archived by the owner on Feb 1, 2020. It is now read-only.
Implement array object compatible array functions #2
Open
Description
Problem
If I use an array object, I am no longer able to use any of the array functions that PHP provides.
$array = new ArrayObject();
// Warning: array_search() expects parameter 2 to be array, object given
$index = array_search(123, $array);
Resolution
Implement the available array functions with support for any ArrayAccess
or Iterator
implementation. The implementations should default to use PHP's array_
functions if an actual array is provided.
use function KHerGe\Arrays\search;
$array = new ArrayObject();
$index = search($array, 123);