当前位置: 首页>>代码示例>>PHP>>正文


PHP Arrays::filter方法代码示例

本文整理汇总了PHP中Arrays::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::filter方法的具体用法?PHP Arrays::filter怎么用?PHP Arrays::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arrays的用法示例。


在下文中一共展示了Arrays::filter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __match

 /**
  * @param array $patterns
  * @return \Closure
  */
 protected static function __match(array $patterns)
 {
     return function (...$args) use($patterns) {
         // [a] -> Bool
         $patternApplies = function ($pattern) use($args) {
             /** @noinspection PhpParamsInspection */
             return Logic::all(Arrays::zipWith(Lambda::apply(), Arrays::map(self::make(), Arrays::init($pattern)), $args));
         };
         try {
             /** @noinspection PhpParamsInspection */
             $getMatchedImplementation = Lambda::compose(Arrays::last(), Arrays::first($patternApplies), Arrays::filter(function ($pattern) use($args) {
                 return count($pattern) - 1 === count($args);
             }));
             return call_user_func_array($getMatchedImplementation($patterns), $args);
         } catch (\Exception $e) {
             throw new IncompletePatternMatchException('Incomplete pattern match expression.');
         }
     };
 }
开发者ID:joseph-walker,项目名称:vector,代码行数:23,代码来源:Pattern.php

示例2: testFilter

 /**
  * @dataProvider provideTestFilter
  */
 public function testFilter($options, $raw, $filtered, $valid)
 {
     $int = new Arrays($options);
     $this->assertEquals($filtered, $int->filter($raw));
     $this->assertEquals($valid, $int->validate($raw));
 }
开发者ID:puwenhan,项目名称:filterus,代码行数:9,代码来源:ArraysTest.php

示例3: filter

 public function filter($function)
 {
     $this->_array = Arrays::filter($this->_array, $function);
     return $this;
 }
开发者ID:exonintrendo,项目名称:Primer,代码行数:5,代码来源:FluentArray.php


注:本文中的Arrays::filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。