mkloubert/php-linq

PHP 的 LINQ 概念。

dev-master 2019-10-30 05:38 UTC

This package is not auto-updated.

Last update: 2024-09-18 17:47:56 UTC


README

PHP 实现的 LINQ 概念。

大多数方法在 .NET 上下文中都是可链式的。

您可以在 wiki 中找到 文档API 文档

特性

要求

示例

完整列表可以在 实时示例页面 中找到。

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'
}

您需要

文件/目录结构

System/
phpLINQ.php

已实现