# indexOf()

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

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

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

//Check array includes "Banana"
$arrayUtils->indexOf("Banana");
// expected output: 1

//Check array includes "Carrot" from 2
$arrayUtils->indexOf("Banana");
// expected output: null

//Check array includes "Baccon"
$arrayUtils->indexOf("Baccon");
// expected output: null
```

{% endcode %}

## Syntax

```php
$arrayUtils->indexOf(mixed $needle, int $start = 0) : int|string|null;
```

### Parameter

* `$needle`
  * The value to search for.
* `$start` <img src="https://2976351099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKYhyHaArG9Gsnmdxc8%2F-MKk9I82AGQBHkmwnVvk%2F-MKk9YjCz_YkVR1YiRy-%2FBADGE_OPTIONAL.svg?alt=media&#x26;token=3fbbac84-2f1b-40af-a991-b2eff659866a" alt="" data-size="line">&#x20;

  * &#x20;The position in this array at which to begin searching for `valueToFind`.
  * &#x20;Defaults to `0`.

### Return value

* The  first index of the element in the array. If not founded, returns `NULL`.

## Prefixing

```php
ArrayUtils::indexOfFrom(iterable $from, mixed $needle, int $start = 0) : int|string|null;
```

## References

<https://www.php.net/manual/en/function.array-chunk>
