git.schokokeks.org
Repositories
Help
Report an Issue
fs-draft.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
589dd2e
Branches
Tags
master
midgard
vorlage
fs-draft.git
source
logic
server
list.php
improved snap-function
Christian Fraß
commited
589dd2e
at 2017-07-25 08:22:29
list.php
Blame
History
Raw
<?php /** */ function list_group($list, $collation = null) { if ($collation == null) { $collation = (function ($x, $y) {return ($x == $y);}); } $groups = []; foreach ($list as $element) { $found = false; $group = null; foreach ($groups as $group_) { if ($collation($group_[0], $element)) { $group = $group_; $found = true; break; } } if (! $found) { $group = []; } array_push($group, $element); if (! $found) { array_push($groups, $group); } } return $groups; } /** */ function list_clean($list, $collation = null) { return ( array_map ( function ($group) {return $group[0];}, list_group($list, $collation) ) ); } ?>