PHPackages                             srph/map-range - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. srph/map-range

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

srph/map-range
==============

A more efficient foreach-range

v0.1.0(10y ago)011MITPHP

Since Aug 26Pushed 10y ago1 watchersCompare

[ Source](https://github.com/srph/map-range)[ Packagist](https://packagist.org/packages/srph/map-range)[ RSS](/packages/srph-map-range/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

map-range [![Build Status](https://camo.githubusercontent.com/bcfe0b25731228b2aaed22a1664eb48c0e8d3fde59082ca1d09b7f22f99ac4df/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f737270682f6d61702d72616e67652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/srph/map-range?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/689a9fd68148dc38d0df230475267ad71d7bbee49b7cbea3b20fb446103376ca/68747470733a2f2f706f7365722e707567782e6f72672f737270682f6d61702d72616e67652f762f737461626c65)](https://packagist.org/packages/srph/map-range) [![Total Downloads](https://camo.githubusercontent.com/7f6b8486f2a62a49a360278e7e10e0536603b2667a1b20975d2b5bd3a1701110/68747470733a2f2f706f7365722e707567782e6f72672f737270682f6d61702d72616e67652f646f776e6c6f616473)](https://packagist.org/packages/srph/map-range) [![Latest Unstable Version](https://camo.githubusercontent.com/37aa623cfb093014b204d43d5c03891fdd4378c394c3f905fecd719b59dfb6f0/68747470733a2f2f706f7365722e707567782e6f72672f737270682f6d61702d72616e67652f762f756e737461626c65)](https://packagist.org/packages/srph/map-range) [![License](https://camo.githubusercontent.com/7f117b28eb0364444340d3527ed9a2950b330db5e04121991e7cce09910f18df/68747470733a2f2f706f7365722e707567782e6f72672f737270682f6d61702d72616e67652f6c6963656e7365)](https://packagist.org/packages/srph/map-range)
===========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#map-range-----)

```
composer require srph/map-range

```

A more efficient `foreach`-`range`.

Usage
-----

[](#usage)

```
SRPH\MapRange\map_range(function($index) {
	// do something
}, $from, $to);
```

For PHP &gt;=v5.6, you can use the use function (aka import function) syntax:

```
use function SRPH\MapRange\map_range;

map_range(function($index) {
	// do something
}, $from, $to);
```

Note that it iterates *while* `$from
