Download the PHP package hi-folks/array without Composer

On this page you can find all versions of the php package hi-folks/array. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package array

Package array

PHP Array package

Latest Version on Packagist PHP Unit Tests Total Downloads Test Coverage

This package provides 2 classes:

Arr class

Arr exposes methods to create, manage, access the data structure of the array.

The interface (method names, method arguments) are pretty similar to the Javascript Array class.

I built this class because comparing method functions arrays of Javascript and PHP i think (my personal thought) that the JS one is smoother and has a good developer experience (but, again, it's a personal opinion).

The Arr class provides some methods:

The get() method

The get() method supports keys/indexes with the dot (or custom) notation for retrieving values from nested arrays. For example:

You can customize the notation with a different character:

You can define a default value in the case the key doesn't exist:

The getArr() method

If you need to manage a complex array (nested array), or an array obtained from a complex JSON structure, you can access a portion of the array and obtain an Arr object. Just because in the case of a complex array the get() method could return a classic array.

Let's see an example:

The set() method

The set() method supports keys with the dot (or custom) notation for setting values for nested arrays. If a key doesn't exist, the set() method will create a new key and will set the value. If a key already exists, the set() method will replace the value related to the key.

For example:

So when you try to set a nested key as "content.0.content.0.text", it will be created elements as a nested array. So if you try to dump the value of the array of $textField you will see the following structure:

Table class

Table class allows you to manage bi-dimensional array, something like:

Each row within the Table will be of type Arr so it allows you to lean on all the methods that are available via the Arr object.

Table class allows you to filter, order, select some fields, create calculated fields. The methods:

Table now implements \Countable and \Iterator, this allows you to count the number of rows and also loop over the rows using common loops.

Installation

You can install the package via composer:

Usage

To see some examples, I suggest you to take a look to examples/cheatsheet.php file,where you can see a lot of example and use cases.

To start quickly

To create an array with random values:

You can access to the elements like a native array, but you have also Arr methods:

Usage of Table class

Starting from:

I would like to filter the rows with price greater than 100, select only "product" and "price" fields, and for each rows create a new field named "new_filed" that is a calculated field (doubling the price):

The result is

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of array with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1|^8.2|^8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hi-folks/array contains the following files

Loading the files please wait ....