{"id":31908305,"url":"https://github.com/enzyme/loopy","last_synced_at":"2025-10-13T15:26:56.544Z","repository":{"id":56978273,"uuid":"47583472","full_name":"enzyme/loopy","owner":"enzyme","description":"A loop library for PHP","archived":false,"fork":false,"pushed_at":"2016-04-03T07:55:12.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-30T03:39:53.734Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/enzyme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-07T22:33:03.000Z","updated_at":"2016-07-08T20:39:45.000Z","dependencies_parsed_at":"2022-08-21T08:10:52.077Z","dependency_job_id":null,"html_url":"https://github.com/enzyme/loopy","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/enzyme/loopy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enzyme%2Floopy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enzyme%2Floopy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enzyme%2Floopy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enzyme%2Floopy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/enzyme","download_url":"https://codeload.github.com/enzyme/loopy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/enzyme%2Floopy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279015918,"owners_count":26085778,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-10-13T15:26:51.023Z","updated_at":"2025-10-13T15:26:56.538Z","avatar_url":"https://github.com/enzyme.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://cloud.githubusercontent.com/assets/2805249/11684981/4d6de34c-9ec1-11e5-97a1-2aee3eb0ab3b.png\" width=\"200\"\u003e\n\n[![Build Status](https://travis-ci.org/enzyme/loopy.svg)](https://travis-ci.org/enzyme/loopy)\n[![Coverage Status](https://coveralls.io/repos/enzyme/loopy/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/enzyme/loopy?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/enzyme/loopy/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/enzyme/loopy/?branch=master)\n\nA loop library for PHP.\n\n# Installation\n\nRun the following command inside of your project directory.\n\n```bash\ncomposer require enzyme/loopy\n```\n\n# Usage\n\n#### Simple\n\nA simple loop over an array.\n\n```php\nuse Enzyme\\Loopy\\Each;\n\n$array = [1, 2, 3];\n\nEach::shallow()-\u003ebegin($array, function($bag) {\n    echo $bag-\u003evalue() . ', ';\n});\n```\n\nThe above will output `1, 2, 3, `\n\n#### Deep\n\nA deep loop over a multidimensional array.\n\n```php\nuse Enzyme\\Loopy\\Each;\n\n$array = [1, 2, 3, 4 =\u003e [4, 5, 6]];\n\nEach::deep()-\u003ebegin($array, function($bag) {\n    echo $bag-\u003evalue() . ', ';\n});\n```\n\nThe above will output `1, 2, 3, 4, 5, 6, `\n\n#### Filtered\n\nA loop over a filtered array.\n\n```php\nuse Enzyme\\Loopy\\Each;\nuse Enzyme\\Loopy\\Filters\\SkipNulls;\n\n$array = [1, 2, null, 4, 5];\n\nEach::deep(new SkipNulls)-\u003ebegin($array, function($bag) {\n    echo $bag-\u003evalue() . ', ';\n});\n```\n\nThe above will output `1, 2, 4, 5, `\n\n# Bags\n\nThe `$bag` object passed to the callback function generally contains the follow information.\n\nKey | Value | Description\n----|-------|------------\nkey() | Key | The enumerable objects key for the given pass.\nvalue() | Value | The enumerable objects value for the given pass.\ncycle() | Current cycle (0 based) | How many times around the entire object the looper has gone.\ndepth() | Current depth (0 based) | The current depth of the pass, for multidimensional arrays.\nindex() | Current index (0 based) | The current index, in this case index is really a count of the number of items encountered so far.\n\n# Filters\n\nFilter | Description\n-------|------------\nSkipNulls | Will skip over any values which are null.\nRegex | Will test value against the supplied regular expression.\nEqual | Will test value for equality against the given rule. (===)\nLess | Will test that value is less than the give rule, or less than or equal if parameter 2 in the constructor is set to true.\nGreater | Will test that value is greater than the give rule, or greater than or equal if parameter 2 in the constructor is set to true.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenzyme%2Floopy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenzyme%2Floopy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenzyme%2Floopy/lists"}