PHPackages                             itools/smartarray - 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. itools/smartarray

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

itools/smartarray
=================

Enhanced PHP arrays with built-in HTML encoding and chainable collection methods

v2.6.4(1mo ago)12112MITPHPPHP ^8.1

Since Oct 28Pushed 2mo agoCompare

[ Source](https://github.com/interactivetools-com/SmartArray)[ Packagist](https://packagist.org/packages/itools/smartarray)[ Docs](https://github.com/interactivetools-com/SmartArray)[ RSS](/packages/itools-smartarray/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (33)Used By (2)

SmartArray: Enhanced Arrays with Chainable Methods and Automatic HTML Encoding
==============================================================================

[](#smartarray-enhanced-arrays-with-chainable-methods-and-automatic-html-encoding)

SmartArray extends PHP arrays with automatic HTML encoding and chainable utility methods. It adds powerful features for filtering, mapping, and data manipulation - making common array operations simpler, safer, and more expressive.

Table of Contents
-----------------

[](#table-of-contents)

- [SmartArray: Enhanced Arrays with Chainable Methods and Automatic HTML Encoding](#smartarray-enhanced-arrays-with-chainable-methods-and-automatic-html-encoding)
    - [Table of Contents](#table-of-contents)
    - [Quick Start](#quick-start)
    - [Usage Examples](#usage-examples)
        - [Highlighting Recent Articles with position()](#highlighting-recent-articles-with-position)
        - [Accessing Elements by Position with nth()](#accessing-elements-by-position-with-nth)
        - [Looking Up Authors by ID with indexBy()](#looking-up-authors-by-id-with-indexby)
        - [Organizing Books by Genre with groupBy()](#organizing-books-by-genre-with-groupby)
        - [Extracting Unique Tags with pluck(), unique(), and implode()](#extracting-unique-tags-with-pluck-unique-and-implode)
        - [Building Dynamic HTML Tables with sprintf()](#building-dynamic-html-tables-with-sprintf)
        - [Creating Grid Layouts with isFirst() and isLast()](#creating-grid-layouts-with-isfirst-and-islast)
        - [Debugging and Help](#debugging-and-help)
    - [Method Reference](#method-reference)
    - [Questions?](#questions)

Quick Start
-----------

[](#quick-start)

Install via Composer:

```
composer require itools/smartarray
```

Include the Composer autoloader and SmartArray class:

```
