{"id":16978701,"url":"https://github.com/srph/map-range","last_synced_at":"2026-04-12T22:11:35.210Z","repository":{"id":57058655,"uuid":"41443644","full_name":"srph/map-range","owner":"srph","description":":curly_loop: A more efficient foreach-range","archived":false,"fork":false,"pushed_at":"2015-08-26T19:35:07.000Z","size":156,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-26T17:15:44.868Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/srph.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-26T18:47:43.000Z","updated_at":"2016-03-06T12:25:55.000Z","dependencies_parsed_at":"2022-08-24T14:53:21.830Z","dependency_job_id":null,"html_url":"https://github.com/srph/map-range","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fmap-range","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fmap-range/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fmap-range/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fmap-range/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/srph","download_url":"https://codeload.github.com/srph/map-range/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244880550,"owners_count":20525511,"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-14T01:44:02.795Z","updated_at":"2025-10-18T12:25:07.500Z","avatar_url":"https://github.com/srph.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# map-range [![Build Status](https://img.shields.io/travis/srph/map-range.svg?style=flat-square)](https://travis-ci.org/srph/map-range?branch=master) [![Latest Stable Version](https://poser.pugx.org/srph/map-range/v/stable)](https://packagist.org/packages/srph/map-range) [![Total Downloads](https://poser.pugx.org/srph/map-range/downloads)](https://packagist.org/packages/srph/map-range) [![Latest Unstable Version](https://poser.pugx.org/srph/map-range/v/unstable)](https://packagist.org/packages/srph/map-range) [![License](https://poser.pugx.org/srph/map-range/license)](https://packagist.org/packages/srph/map-range)\n```\ncomposer require srph/map-range\n```\nA more efficient `foreach`-`range`.\n\n## Usage\n\n```php\nSRPH\\MapRange\\map_range(function($index) {\n\t// do something\n}, $from, $to);\n```\n\nFor PHP \u003e=v5.6, you can use the use function (aka import function) syntax:\n\n```php\nuse function SRPH\\MapRange\\map_range;\n\nmap_range(function($index) {\n\t// do something\n}, $from, $to);\n```\n\nNote that it iterates *while* `$from \u003c= $to`.\n\n## Why\nBecause some developers prefer this\n```php\nforeach(range(0, 10) as $i) {\n\t// ..\n} \n```\n\nOver this:\n```php\nfor ( $i = 0; $i \u003c 10; $i++ ) {\n\t//\n}\n```\n\nIn which the first example generates a buffer array first (which is terrible for performance).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrph%2Fmap-range","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrph%2Fmap-range","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrph%2Fmap-range/lists"}