{"id":16078365,"url":"https://github.com/codeliner/array-reader","last_synced_at":"2025-03-18T05:31:25.373Z","repository":{"id":14827476,"uuid":"17550225","full_name":"codeliner/array-reader","owner":"codeliner","description":"PHP ArrayReader","archived":false,"fork":false,"pushed_at":"2020-04-06T18:50:38.000Z","size":16,"stargazers_count":19,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T07:34:54.082Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeliner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-08T20:25:21.000Z","updated_at":"2021-02-02T08:34:45.000Z","dependencies_parsed_at":"2022-09-23T23:21:21.544Z","dependency_job_id":null,"html_url":"https://github.com/codeliner/array-reader","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeliner%2Farray-reader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeliner%2Farray-reader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeliner%2Farray-reader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeliner%2Farray-reader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeliner","download_url":"https://codeload.github.com/codeliner/array-reader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243903180,"owners_count":20366438,"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":[],"created_at":"2024-10-09T10:11:55.032Z","updated_at":"2025-03-18T05:31:21.208Z","avatar_url":"https://github.com/codeliner.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"array-reader\n============\n\nPHP ArrayReader\n\n[![Build Status](https://travis-ci.org/codeliner/array-reader.png?branch=master)](https://travis-ci.org/codeliner/array-reader)\n\n\n## Installation\n\nInstallation of codeliner\\array-reader uses composer. For composer documentation, please refer to\n[getcomposer.org](http://getcomposer.org/).\nAdd following requirement to your composer.json\n\n```sh\n\"codeliner/array-reader\" : \"~2.0\"\n```\n\n## Usage\n\nYou can use the ArrayReader to read single values from a multidimensional array by passing the path to one\nof the `{type}Value()` methods. Each `{type}Value()` method takes a default value as second argument If the path can\nnot be found in the original array, the default is used as return value.\n\n## Example\n\n```php\n$arrayReader = new ArrayReader(\n    array(\n        'hash' =\u003e array(\n            'with' =\u003e array(\n                'nested' =\u003e 'value'\n            )\n        )\n    )\n);\n\necho $arrayReader-\u003estringValue('hash.with.nested'));\n\n//Output: value\n\n$arrayReader = new ArrayReader(\n    array(\n        'hash' =\u003e array(\n            'with' =\u003e array(\n                'nested' =\u003e 'value'\n            )\n        )\n    )\n);\n\necho $arrayReader-\u003estringValue('hash.not.existing.path', 'defaultString'));\n\n//Output: defaultString\n\n\n//If a key in your array contains a dot you escape it in the path with a backslash\n\n$arrayReader = new ArrayReader(\n    array(\n        'hash' =\u003e array(\n            'with.dot.key' =\u003e array(\n                'nested' =\u003e 'value'\n            )\n        )\n    )\n);\n\necho $arrayReader-\u003estringValue('hash.with\\.dot\\.key.nested'));\n\n//Output: value\n\n//If you need to differentiate between a NULL value and a not existing path, you can explicity check if the path exists:\n\n$arrayReader = new ArrayReader(\n    array(\n        'hash' =\u003e array(\n            'with' =\u003e array(\n                'nested' =\u003e null\n            )\n        )\n    )\n);\n\nif($arrayReader-\u003epathExists('hash.with.nested')) {\n    echo \"path exists\";\n}\n\n//Output: path exists\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeliner%2Farray-reader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeliner%2Farray-reader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeliner%2Farray-reader/lists"}