# find()

{% code title="Example.php" %}

```php
<?php use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(["Apple", "Banana", "Carrot", "Bacon"]);

//Find values ​​starting with B
$arrayUtils->find(function($name){ return $name[0] === "B"; });
// expected output: "Banana"
```

{% endcode %}

## Syntax

```php
$arrayUtils->find(callable $callback) : mixed;
```

### Parameter

* `$callback`

  > A function to execute on each value in the array, taking 3 arguments:
  >
  > * `$value` The current element being processed in the array.
  > * `$key` The index of the current element being processed in the array.
  > * `$array`  The array `every` was called upon.

###

### Return value

* &#x20;The **value** of the **first element** in the array that pass function.\
  Otherwise, `NULL` is returned.

## Prefixing

```php
ArrayUtils::findFrom(iterable $from, callable $callback) : mixed;
```

## References

{% embed url="<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://arrayutils.docs.present.kim/methods/g/find.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
