PHPackages                             angus-dv/in\_array\_r - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. angus-dv/in\_array\_r

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

angus-dv/in\_array\_r
=====================

Provides functionality for in\_array\_r() to projects using PHP earlier than version 5.5 or greater.

v1.0.4(1y ago)08MITPHP

Since Aug 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/AngusDV/in_array_r)[ Packagist](https://packagist.org/packages/angus-dv/in_array_r)[ Docs](https://github.com/AngusDV/in_array_r)[ RSS](/packages/angus-dv-in-array-r/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

in\_array\_r() for PHP
======================

[](#in_array_r-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/af3eca10a2e26d64737dbe43a4cc4838101a76ad200a14f4473582ea2a421bdb/68747470733a2f2f706f7365722e707567782e6f72672f616e6775732d64762f696e5f61727261795f722f76)](https://packagist.org/packages/angus-dv/in_array_r)[![Total Downloads](https://camo.githubusercontent.com/6c9f2d2dc1150b4e969b988084922907151e3ce998570f56c6c399231e9ccff1/68747470733a2f2f706f7365722e707567782e6f72672f616e6775732d64762f696e5f61727261795f722f646f776e6c6f616473)](https://packagist.org/packages/angus-dv/in_array_r)[![Latest Unstable Version](https://camo.githubusercontent.com/9a727db9966def723fec6414e338ece1821496cc1d95fbad08208935d5054de0/68747470733a2f2f706f7365722e707567782e6f72672f616e6775732d64762f696e5f61727261795f722f762f756e737461626c65)](https://packagist.org/packages/angus-dv/in_array_r)[![License](https://camo.githubusercontent.com/62a19eb006e98f359ed42308ec0583fbbc4fea47bd393b57cf266d3a89c5f567/68747470733a2f2f706f7365722e707567782e6f72672f616e6775732d64762f696e5f61727261795f722f6c6963656e7365)](https://packagist.org/packages/angus-dv/in_array_r)[![PHP Version Require](https://camo.githubusercontent.com/4a860bc38adb8b58b9fdc21f33774d4b0c3c2fe94d24a9b2b0a512762be1dc8f/68747470733a2f2f706f7365722e707567782e6f72672f616e6775732d64762f696e5f61727261795f722f726571756972652f706870)](https://packagist.org/packages/angus-dv/in_array_r)

The `in_array_r()` function is not a built-in PHP function, but rather a custom function that can be used to recursively check if a given `$needle` (string or integer) exists within a multi-dimensional `$haystack` array.

Usage
-----

[](#usage)

```
array in_array_r(string|int $needle, array $haystack,bool $strict = false)

```

The function takes three parameters:

1. `$needle`: The value (string or integer) to search for.
2. `$haystack`: The array (or multi-dimensional array) to search in.
3. `$strict`: (Optional) A boolean value that determines whether the search should be strict (using the `===` operator) or not (using the `==` operator).

The function first checks if the `$haystack` is an array. If it is, it loops through each item in the array. For each item, it checks if the item matches the `$needle` (using either the strict or non-strict comparison, based on the `$strict` parameter). If a match is found, the function returns `true`.

If the item is another array, the function recursively calls itself with the current item as the new `$haystack`. This allows the function to search through nested arrays until a match is found or the entire `$haystack` has been searched.

If no match is found after searching the entire `$haystack`, the function returns `false`.

So, to answer your question, the `in_array_r()` function can be used to check if a given value (string or integer) exists within a multi-dimensional array. It will search through all the nested arrays and return `true` if the `$needle` is found, and `false` otherwise.

Installation
------------

[](#installation)

The easiest way to install this library is to use [Composer](https://getcomposer.org/):

```
composer require angus-dv/in_array_r

```

Then, when you run `composer install`, everything will fall magically into place, and the `in_array_r()` function will be available to your project, as long as you are including Composer's autoloader.

*However, you do not need Composer to use this library.*

This library has no dependencies and should work on older versions of PHP. Download the code and include `src/in_array_r.php` in your project, and all should work fine.

When you are ready to run your project on PHP 5.5 or greater than, everything should continue to run well without conflicts, even if this library remains included in your project.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

629d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/40d6f1d20980036a861daddcf3eea18ac7b2a2bde4f81a4d05c07af410df195b?d=identicon)[marooj](/maintainers/marooj)

---

Top Contributors

[![AngusDV](https://avatars.githubusercontent.com/u/5556823?v=4)](https://github.com/AngusDV "AngusDV (16 commits)")

---

Tags

arraycolumnin\_array\_r

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/angus-dv-in-array-r/health.svg)

```
[![Health](https://phpackages.com/badges/angus-dv-in-array-r/health.svg)](https://phpackages.com/packages/angus-dv-in-array-r)
```

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k411.1M1.2k](/packages/doctrine-collections)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[league/config

Define configuration arrays with strict schemas and access values with dot notation

564302.2M24](/packages/league-config)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[openlss/lib-array2xml

Array2XML conversion library credit to lalit.org

31052.5M47](/packages/openlss-lib-array2xml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
