Searches the array for a given value and returns the first corresponding key if successful.

/**
 * Searches the array for a given value and returns the first corresponding key if successful.
 *
 * @param mixed $needle The searched value.
 */
public function search($needle)

Examples

$result = Arrays::create([0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red'])->search('green');

print_r($result);

The above example will output:

2

Getting Started

Methods