PHPackages                             ataur/binarray - 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. ataur/binarray

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

ataur/binarray
==============

An alternative way to handle large volumn of integer or short string as array in memory efficient way.

016PHP

Since Mar 27Pushed 8y ago1 watchersCompare

[ Source](https://github.com/SMAtaurRahman/Binarray)[ Packagist](https://packagist.org/packages/ataur/binarray)[ RSS](/packages/ataur-binarray/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

What is Binarray?
-----------------

[](#what-is-binarray)

> An alternative way to handle large volumn of integer or short string as array in memory efficient way.

**Wait, What???**

Let's say you need to have a large chunk of array containing millions of elements.
First thing anyone would try is to do it with `array()`

Whats wrong with `array()`?

There's nothing wrong with `array()`, rather it's an awesome tool in php to get things done.
But in reality, It's little bit more memory hungry. To have milions on element in class `array`, you would need hundreds of MB memory.
Even though PHP7 restructured array internals, still they eat lots of memory.

How will Binarray will help me?

Binarray is not actually array at all, It will store your values in a single variable and retrieve it when you want. It does not provide any of other features that `array()` provides. As it stores all data to a single variable, it tends to use less memory.

But will it be as fast as `array()`?

> There is no solution, only trade-offs

Binarray won't be as fast as array at all. As it will eat low memory, in return it will work much slower and eat up cpu usage a little bit more.
But there will be some case where you don't care about slowing down few seconds, Binarray will be handy in that case.

**I still can't find any reason to use Binarray instead of array**

Yeah, you can't use Binarray instead of array.
Binarray has just set/get functionality, It can't do anything other than that.

**You can use Binarray when -**

- You need to have one-dimentional array containing millions of simple integer or string.

**You can't use Binarray when -**

- You need anything else.

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

[](#installation)

```
composer require ataur/binarray
```

Usage
-----

[](#usage)

```
