PHPackages                             serafim/packed-array - 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. serafim/packed-array

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

serafim/packed-array
====================

Typed arrays with reduced memory consumption

1021[1 issues](https://github.com/SerafimArts/PackedArray/issues)PHP

Since Apr 3Pushed 3y ago1 watchersCompare

[ Source](https://github.com/SerafimArts/PackedArray)[ Packagist](https://packagist.org/packages/serafim/packed-array)[ RSS](/packages/serafim-packed-array/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

 [![PHP 8.1+](https://camo.githubusercontent.com/1ec13d092b8366eb285f5cd2c1d83b2bf897b20826ad5ed22599476956dd5035/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f7061636b65642d61727261792f726571756972652f7068703f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/packed-array) [![Latest Stable Version](https://camo.githubusercontent.com/1f8239d30f60ac239714a9e2a37dddb083d62eee85f162aab545ab2a461190b9/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f7061636b65642d61727261792f76657273696f6e3f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/packed-array) [![Latest Unstable Version](https://camo.githubusercontent.com/103dba4601c9670fc623c01591945cf085304b2c55ded8e333ccb797646a2771/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f7061636b65642d61727261792f762f756e737461626c653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/packed-array) [![Total Downloads](https://camo.githubusercontent.com/7258bc1974f4aa08208db05ff3f4b2184bc2a8aba6f9576d2908cc217fa14a40/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f7061636b65642d61727261792f646f776e6c6f6164733f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/packed-array) [![License MIT](https://camo.githubusercontent.com/e7b162c5f73d2fbd4141b0952c2c05f91495b127b4b2228defc116e1bbb498cc/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f7061636b65642d61727261792f6c6963656e73653f7374796c653d666f722d7468652d6261646765)](https://raw.githubusercontent.com/SerafimArts/PackedArray/master/LICENSE.md)

 [![](https://github.com/SerafimArts/PackedArray/workflows/tests/badge.svg)](https://github.com/SerafimArts/PackedArray/actions)

Introduction
------------

[](#introduction)

PHP packed (typed) arrays are array-like objects that provide a mechanism for reading and writing raw binary data in memory buffers with reduced memory consumption on large amounts of data.

Common PHP arrays grow and shrink dynamically and can have any value. PHP Zend VM perform optimizations so that these arrays are fast. However, in some cases, the standard functionality is not enough and the standard PHP array can take up a very large amount of data, for example, when working with audio, image and video. This is where typed arrays come in. Each entry in a PHP typed array is a raw binary value in one of a number of supported formats, from 8-bit integers to 64-bit floating-point numbers.

For example, an image with a size of **44.968Kb**, when loaded into a typed array, takes **45.168Kb** of memory. However, if it is unpacked into a native PHP array, then the size of such an image in memory will take **5,633.360Kb**. That is more than 120 times!

Below is a graph of the size of the consumed RAM depending on the size of the array (number of elements).

[![/resources/memory-usage.png](/resources/memory-usage.png)](/resources/memory-usage.png)

> See the [bin/memory-usage.php](bin/memory-usage.php) for details on how the this RAM consumption was calculated.

### Read/Write

[](#readwrite)

Please note that such arrays are designed to store a large amount of data, however, they are noticeably slower than those builtin PHP arrays during reading and writing.

#### Reading

[](#reading)

subjectrevsitsmem\_peakmoderstdevbenchNative1000051.291mb0.018μs±1.83%benchSplFixedArray1000051.291mb0.028μs±3.06%benchPackedInt81000051.291mb0.087μs±1.37%benchPackedUInt81000051.291mb0.079μs±1.65%benchPackedInt161000051.291mb0.104μs±1.12%benchPackedUInt161000051.291mb0.108μs±10.24%benchPackedInt321000051.291mb0.159μs±1.06%benchPackedUInt321000051.291mb0.174μs±0.98%benchPackedInt641000051.291mb0.160μs±0.55%benchPackedFloat321000051.291mb1.225μs±1.46%benchPackedFloat641000051.291mb1.232μs±1.33%#### Writing

[](#writing)

subjectrevsitsmem\_peakmoderstdevbenchNative1000051.291mb0.019μs±2.52%benchSplFixedArray1000051.291mb0.032μs±2.10%benchPackedInt81000051.291mb0.088μs±2.45%benchPackedUInt81000051.291mb0.089μs±0.50%benchPackedInt161000051.291mb0.108μs±1.42%benchPackedUInt161000051.291mb0.121μs±4.27%benchPackedInt321000051.291mb0.146μs±1.49%benchPackedUInt321000051.291mb0.153μs±1.62%benchPackedInt641000051.291mb0.220μs±1.79%benchPackedFloat321000051.291mb1.268μs±0.91%benchPackedFloat641000051.291mb1.343μs±0.44%Installation
------------

[](#installation)

This library is available as Composer repository and can be installed using the following command in a root of your project:

```
$ composer require serafim/packed-array
```

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

[](#quick-start)

TODO

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity22

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://avatars.githubusercontent.com/u/150420?v=4)[Ruslan Sharipov](/maintainers/Serafim)[@serafim](https://github.com/serafim)

---

Top Contributors

[![SerafimArts](https://avatars.githubusercontent.com/u/2461257?v=4)](https://github.com/SerafimArts "SerafimArts (26 commits)")

### Embed Badge

![Health badge](/badges/serafim-packed-array/health.svg)

```
[![Health](https://phpackages.com/badges/serafim-packed-array/health.svg)](https://phpackages.com/packages/serafim-packed-array)
```

PHPackages © 2026

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