2017 © Pedro Peláez
 

library map-range

A more efficient foreach-range

image

srph/map-range

A more efficient foreach-range

  • Wednesday, August 26, 2015
  • by srph
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

map-range Build Status Latest Stable Version Total Downloads Latest Unstable Version License

composer require srph/map-range

A more efficient foreach-range., (*1)

Usage

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

For PHP >=v5.6, you can use the use function (aka import function) syntax:, (*2)

use function SRPH\MapRange\map_range;

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

Note that it iterates while $from <= $to., (*3)

Why

Because some developers prefer this, (*4)

foreach(range(0, 10) as $i) {
    // ..
} 

Over this:, (*5)

for ( $i = 0; $i < 10; $i++ ) {
    //
}

In which the first example generates a buffer array first (which is terrible for performance)., (*6)

The Versions

26/08 2015

dev-master

9999999-dev

A more efficient foreach-range

  Sources   Download

MIT

The Development Requires

by Avatar srph

26/08 2015

v0.1.0

0.1.0.0

A more efficient foreach-range

  Sources   Download

MIT

The Development Requires

by Avatar srph