Skip to content

Instantly share code, notes, and snippets.

View firegate666's full-sized avatar

Marco Behnke firegate666

View GitHub Profile
@firegate666
firegate666 / foreach_ext.php
Created November 22, 2011 10:35
extended foreach method with extra information about first and last elements, number of elements, actual index
<?php
/**
* Call callback function for every element of an array and provide some extra information for each element
*
* @param array $array
* @param Callback/Closure $callback
* Callback/Closure must have 6 parameters
* mixed key: key of item
* mixed value: value of item
* integer counter: human readable index of item; starts with 1
@firegate666
firegate666 / fizz_buzz_configurable.php
Last active December 27, 2015 00:59
This is a free configurable implementation of the fizzbuzz problem
<?php
$config = array(
'fizz' => 3,
'buzz' => 5,
/*
'prim' => function($num) {
return in_array($num, array(1, 2, 3, 5, 7, 11, 13, 17, 19, 23));
}
*/
);