ale/string-array

dev-master 2016-04-12 22:00 UTC

This package is not auto-updated.

Last update: 2024-04-19 17:18:14 UTC


README

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Total Downloads License

This is an experimental library that intends to provide access to a C-like array within PHP. I cannot say whether this is a good idea or not, it mainly depends on your use case.

The current implementation uses a PHP string to avoid the memory overhead of using PHP's native hash table of Zvals to implement an array of arrays. This sacrifices speed for memory.

For even more (and slower) memory, you could consider shifting parts of the string off into files.

As an informal example, a 10000x1000 StringArray (10,000,000 data cells) takes about 40MB and takes about 10s to populate on an ok-ish laptop. The same in nested PHP arrays can be done in about half the time, but takes 1.4GB. I can easily test a StringArray of 10000x10000, which takes about 400MB, but it becomes prohibitive to test that size of array with native PHP arrays.

The question might well be "what possible use case requires that much memory but can afford to take that much time?" Well, I leave that up to you.

Installation

string-array can be installed with Composer by adding it as a dependency to your project's composer.json file.

{
    "require": {
        "ale/string-array": "*"
    }
}

Please refer to Composer's documentation for more detailed installation and usage instructions.

Usage

@todo

TODO

I'm not sure when any of these will get done.

  • Testing
  • Currently, only 32-bit ints are handled. More types should be possible, chars would be super easy.