mkloubert / php-linq
LINQ concept for PHP.
Fund package maintenance!
paypal.me/MarcelKloubert
Installs: 132
Dependents: 0
Suggesters: 0
Security: 0
Stars: 41
Watchers: 4
Forks: 13
Open Issues: 0
This package is not auto-updated.
Last update: 2025-02-05 19:28:39 UTC
README
Most methods are chainable as in .NET context.
Here you can find the DOCUMENTATION in the wiki or the API documentation.
Features
- Lambda expressions
- Any kind of lists or iterators can be used
- Most methods are chainable as in .NET context
- Enhancements / improvements for use in PHP context
Requirements
Example
A complete list can be found at the live example page.
use \System\Linq; $seq = Enumerable::fromValues(5979, 23979, null, 23979, 1781, 241279); $newSeq = $seq->select('$x => (string)$x') // transform all values // to string ->where('$x => !empty($x)') // filter out all values that are empty ->skip(1) // skip the first element ('5979') ->take(3) // take the next 3 elements from current position // ('23979', '23979' and '1781') ->distinct() // remove duplicates ->order(); // sort foreach ($newSeq as $item) { // [0] '1781' // [1] '23979' }
What you need
- The phpLINQ.php file
- The whole System folder
The file / directory structure:
System/
phpLINQ.php
Implemented
- aggregate()
- all()
- any()
- average()
- cast()
- concat()
- contains()
- count()
- defaultIfEmpty()
- distinct()
- elementAt()
- elementAtOrDefault()
- except()
- first()
- firstOrDefault()
- groupBy()
- groupJoin()
- intersect()
- join()
- last()
- lastOrDefault()
- max()
- min()
- ofType()
- orderBy()
- orderByDescending()
- reverse()
- select()
- selectMany()
- sequenceEqual()
- single()
- singleOrDefault()
- skip()
- skipWhile()
- sum()
- take()
- takeWhile()
- toArray()
- toDictionary()
- toList()
- toLookup()
- union()
- where()
- zip()