Skip to content
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
@kherge

Description

@kherge

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);

References

  1. http://php.net/manual/en/ref.array.php

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions