PHPackages                             grayspacecoding/render-recursive - 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. grayspacecoding/render-recursive

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

grayspacecoding/render-recursive
================================

A flexible utility for rendering recursive data sets.

00PHP

Since Dec 9Pushed 5mo agoCompare

[ Source](https://github.com/grayspacecoding/Render-Recursive)[ Packagist](https://packagist.org/packages/grayspacecoding/render-recursive)[ RSS](/packages/grayspacecoding-render-recursive/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Render Recursive
================

[](#render-recursive)

A flexible PHP utility for rendering recursive/nested data structures with customizable output formatting.

Overview
--------

[](#overview)

Render Recursive provides a simple yet powerful way to traverse multidimensional arrays or hierarchical data and generate visualizations (typically HTML). It uses a callback-based approach that gives you full control over how each level and item in your data structure is rendered.

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

[](#installation)

Install via Composer:

```
composer require grayspacecoding/render-recursive
```

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4

Basic Usage
-----------

[](#basic-usage)

```
use Grayspacecoding\RenderRecursive\RenderTiers;

$data = [
    'Item 1',
    'Item 2',
    [
        'Nested Item 1',
        'Nested Item 2',
        [
            'Deeply Nested Item'
        ]
    ],
    'Item 3'
];

$renderer = new RenderTiers();
$renderer->call($data);
```

This produces a nested `` list by default.

How It Works
------------

[](#how-it-works)

The `call()` method accepts up to 5 parameters:

1. **`$data`** (required) - Your multidimensional array/data structure
2. **`$wrapperCallback`** (optional) - How to wrap the entire output
3. **`$arrayCallback`** (optional) - How to handle items with descendants (array items)
4. **`$itemCallback`** (optional) - How to handle leaf items (non-array items)
5. **`$childDeterminer`** (optional) - Logic to determine if an item has children

Customization
-------------

[](#customization)

### Custom Item Rendering

[](#custom-item-rendering)

```
$renderer->call($data, null, null, function($item) {
    echo "" . htmlspecialchars($item) . "";
});
```

### Custom Array (Branch) Rendering

[](#custom-array-branch-rendering)

```
$renderer->call($data, null, function($item) {
    echo "";
    // Recursion happens here automatically
    echo "";
}, null);
```

### Custom Wrapper

[](#custom-wrapper)

```
$renderer->call($data, function($content) {
    echo "" . $content . "";
});
```

### Custom Child Determiner

[](#custom-child-determiner)

By default, `is_array()` determines if an item has children. You can customize this:

```
$renderer->call($data, null, null, null, function($item) {
    // Custom logic, e.g., for objects with a 'children' property
    return is_object($item) && isset($item->children) && count($item->children) > 0;
});
```

Complete Example
----------------

[](#complete-example)

```
$data = [
    'Home',
    'About',
    [
        'Team',
        'History',
        [
            'Timeline',
            'Milestones'
        ]
    ],
    'Contact'
];

$renderer = new RenderTiers();

$renderer->call(
    $data,
    // Wrapper
    function($content) {
        echo "" . $content . "";
    },
    // Array callback
    function($item) {
        echo "";
        // Recursion happens automatically within the library
        echo "";
    },
    // Item callback
    function($item) {
        echo "" . htmlspecialchars($item) . "";
    }
);
```

Default Behaviors
-----------------

[](#default-behaviors)

If you don't provide callbacks, the following defaults are used:

- **Wrapper**: Wraps output in ``
- **Array items**: Wraps in `` and recurses
- **Leaf items**: Wraps in `` with HTML-escaped content
- **Child determination**: Uses `is_array()`

Use Cases
---------

[](#use-cases)

- Rendering nested navigation menus
- Displaying hierarchical category trees
- Visualizing organizational structures
- Converting nested data to HTML lists
- Building recursive tree components
- Creating nested accordion interfaces

License
-------

[](#license)

MIT

Authors
-------

[](#authors)

- Parseley Devs ()

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance49

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/36d2aa3222d7808017a0e58d0d92c5bb05940a9b90b1795707e0a40095f13531?d=identicon)[grayspacecoding](/maintainers/grayspacecoding)

---

Top Contributors

[![grayspacecoding](https://avatars.githubusercontent.com/u/38174923?v=4)](https://github.com/grayspacecoding "grayspacecoding (3 commits)")

### Embed Badge

![Health badge](/badges/grayspacecoding-render-recursive/health.svg)

```
[![Health](https://phpackages.com/badges/grayspacecoding-render-recursive/health.svg)](https://phpackages.com/packages/grayspacecoding-render-recursive)
```

PHPackages © 2026

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