Download the PHP package pavlyuts/php-string-key-arrays without Composer

On this page you can find all versions of the php package pavlyuts/php-string-key-arrays. 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 php-string-key-arrays

Array-like class with only strings used as keys

Purpose

PHP arrays may be veery frustrating with it's mess in key string/integer and associated probems.

It was need to ensure the keys will work predictable as string, but the class still be used as a regular array with $a['key'] syntax, foreach use and all other staff. So, this what it do!

Installation

In the Composer storage. Just add proper require section:

"require": {
    "pavlyuts/php-string-key-arrays": "*"
}

I do not think there be a version compatibility problem as it is too simple thing and expected to be stable. However, I recommend to inspect CHANGELOG.md for changes.

Use

Basics

Basic use about the same as array but with some limitations described below.

Some useful functions also available in the section below

Examples

Limitations

Useful functions

keys() aka array_keys()

Call of $stringKeyArray->keys() or it's synonym array_keys() returns keys as array of strings, same as PHP analogue.

values() aka array_values()

Call of $stringKeyArray->values() or it's synonym array_values() returns values as array of mixed, same as PHP analuue.

merge()

Merges another iterable into SKArray about the same way as array_merge(), but all kays handled as string type

column()

About the same like array_column but... a bit different!

it always returm SKArray class, containing the same string keys and result for each element's 'column' as:

The returned dataset will only include keys and values successfully retrieved, no nulls, no errors. If yo try to access protected method or property it will be silently passed without returning any result or any kind of problem indication.

setSubarrayItem()

Helper to work with SKArray elements type of array, do the same as illegal operaton $stringKeyArray['Level1Key']['Level2key'] = 'value'

If the element of SKArray collection at $offset is not an array or does not exist it will overwrite/create it as an empty array. Then, it will add to array, if key is given, it will add with $key, if null or missed - add as []

Testing

Was tested with PHPUnit 8.5 under PHP 7.2. The code is very simple so expected to work 7.x and up.

If you have doubts about your environment, install it with --dev composer optiion and then run composer test from library source root.


All versions of php-string-key-arrays with dependencies

PHP Build Version
Package Version
No informations.
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 pavlyuts/php-string-key-arrays contains the following files

Loading the files please wait ....