{"id":25257505,"url":"https://github.com/czproject/arrays","last_synced_at":"2025-04-06T00:41:50.959Z","repository":{"id":56960974,"uuid":"66102442","full_name":"czproject/arrays","owner":"czproject","description":"Array tools library.","archived":false,"fork":false,"pushed_at":"2023-03-13T14:25:48.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T06:53:54.048Z","etag":null,"topics":["arrays","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/czproject.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://www.janpecha.cz/donate/"}},"created_at":"2016-08-19T18:08:09.000Z","updated_at":"2023-07-11T05:31:05.000Z","dependencies_parsed_at":"2025-02-12T06:40:19.931Z","dependency_job_id":"25922cde-2d5c-4ea4-b22a-d864a2edc1ff","html_url":"https://github.com/czproject/arrays","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czproject%2Farrays","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czproject%2Farrays/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czproject%2Farrays/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czproject%2Farrays/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/czproject","download_url":"https://codeload.github.com/czproject/arrays/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419813,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arrays","php"],"created_at":"2025-02-12T06:40:13.781Z","updated_at":"2025-04-06T00:41:50.941Z","avatar_url":"https://github.com/czproject.png","language":"PHP","funding_links":["https://www.janpecha.cz/donate/"],"categories":[],"sub_categories":[],"readme":"# CzProject\\Arrays\n\n[![Build Status](https://github.com/czproject/arrays/workflows/Build/badge.svg)](https://github.com/czproject/arrays/actions)\n[![Downloads this Month](https://img.shields.io/packagist/dm/czproject/arrays.svg)](https://packagist.org/packages/czproject/arrays)\n[![Latest Stable Version](https://poser.pugx.org/czproject/arrays/v/stable)](https://github.com/czproject/arrays/releases)\n[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/czproject/arrays/blob/master/license.md)\n\nArray tools library.\n\n\u003ca href=\"https://www.janpecha.cz/donate/\"\u003e\u003cimg src=\"https://buymecoffee.intm.org/img/donate-banner.v1.svg\" alt=\"Donate\" height=\"100\"\u003e\u003c/a\u003e\n\n\n## Installation\n\n[Download a latest package](https://github.com/czproject/arrays/releases) or use [Composer](http://getcomposer.org/):\n\n```\ncomposer require czproject/arrays\n```\n\n`CzProject\\Arrays` requires PHP 5.6.0 or later.\n\n\n## Usage\n\n\n``` php\nuse CzProject\\Arrays;\n\n```\n\n### `flatten()`\n\n``` php\n$data = Arrays::flatten(array(\n\t'value 1',\n\t'values' =\u003e array(\n\t\t'value 2-1',\n\t\t'value 2-2',\n\t\t'value 2-3',\n\t),\n\t'value 3',\n));\n\n/* Returns:\n[\n\t'value 1',\n\t'value 2-1',\n\t'value 2-2',\n\t'value 2-3',\n\t'value 3',\n]\n*/\n```\n\n\n### `fetchPairs()`\n\n``` php\n$rows = array(\n\tarray(\n\t\t'id' =\u003e 1,\n\t\t'name' =\u003e 'Row #1',\n\t),\n\n\tarray(\n\t\t'id' =\u003e 2,\n\t\t'name' =\u003e 'Row #2',\n\t),\n\n\tarray(\n\t\t'id' =\u003e 3,\n\t\t'name' =\u003e 'Row #3',\n\t),\n);\n\n$data = Arrays::fetchPairs($rows, 'id', 'name');\n\n/* Returns:\n[\n\t1 =\u003e 'Row #1',\n\t2 =\u003e 'Row #2',\n\t3 =\u003e 'Row #3',\n]\n*/\n```\n\n\n### `merge()`\n\n``` php\n$defaultConfig = array(\n\t'parameters' =\u003e array(\n\t\t'database' =\u003e array(\n\t\t\t'host' =\u003e 'localhost',\n\t\t\t'database' =\u003e 'lorem_ipsum',\n\t\t\t'driver' =\u003e 'mysql',\n\t\t),\n\t),\n\n\t'messages' =\u003e array(\n\t\t'success' =\u003e 'Success!',\n\t\t'error' =\u003e 'Error!',\n\t),\n);\n\n$config = array(\n\t'parameters' =\u003e array(\n\t\t'database' =\u003e array(\n\t\t\t'user' =\u003e 'user123',\n\t\t\t'password' =\u003e 'password123',\n\t\t),\n\t),\n\n\t'messages' =\u003e array(\n\t\t'error' =\u003e 'Fatal Error!',\n\t),\n);\n\n$data = Arrays::merge($config, $defaultConfig);\n\n/* Returns:\n[\n\tparameters =\u003e [\n\t\tdatabase =\u003e [\n\t\t\thost =\u003e 'localhost',\n\t\t\tdatabase =\u003e 'lorem_ipsum',\n\t\t\tdriver =\u003e 'mysql',\n\t\t\tuser =\u003e 'user123',\n\t\t\tpassword =\u003e 'password123',\n\t\t]\n\t],\n\n\tmessages =\u003e [\n\t\tsuccess =\u003e 'Success!',\n\t\terror =\u003e 'Fatal Error!',\n\t]\n]\n*/\n```\n\n\n### `pushFrom()`\n\n``` php\n$a = ['A1', 'A2', 'A3', 'A4'];\n$b = ['B1', 'B2'];\n$result = [];\n\nfor ($i = 0; $i \u003c 4; $i++) {\n\tArrays::pushFrom($result, $a);\n\tArrays::pushFrom($result, $b);\n}\n\n/* Returns:\n[\n\t'A1',\n\t'B1',\n\t'A2',\n\t'B2',\n\t'A3',\n\t'A4',\n]\n*/\n```\n\n------------------------------\n\nLicense: [New BSD License](license.md)\n\u003cbr\u003eAuthor: Jan Pecha, https://www.janpecha.cz/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczproject%2Farrays","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fczproject%2Farrays","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczproject%2Farrays/lists"}