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


PHP CMap::filter方法代码示例

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


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

示例1: knownNamesForCountry

 /**
  * Returns the names of the time zones that are known for a specified country.
  *
  * If the country's code is not recognized for any reason, the entire list of the known time zone names is
  * returned.
  *
  * @param  string $countryCode The two-letter code of the country, as provided by ISO 3166.
  *
  * @return CArrayObject The known time zone names for the country specified, of type `CUStringObject`.
  */
 public static function knownNamesForCountry($countryCode)
 {
     assert('is_cstring($countryCode)', vs(isset($this), get_defined_vars()));
     $paNames = DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, $countryCode);
     $paNames = CMap::filter($paNames, "CTimeZone::isNameIcuCompatible");
     $names = CArray::fromPArray($paNames);
     if (is_cmap($paNames) && !CArray::isEmpty($names)) {
         return oop_a($names);
     } else {
         return oop_a(self::knownNames());
     }
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:22,代码来源:CTimeZone.php

示例2: filter

 /**
  * Filters the key-value pairs in a map by calling a function or method on each value and returns a new map with
  * only those key-value pairs that were let through by the filter.
  *
  * The map is not modified by this method.
  *
  * @param  callable $filter The function or method to be used for filtering. The filter should take a value as a
  * parameter and return `true` if the corresponding key-value pair should make its way into the resulting map and
  * `false` if not.
  *
  * @return CMapObject The filtered map.
  */
 public function filter($filter)
 {
     return self::fromPArray(CMap::filter($this->m_map, $filter));
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:16,代码来源:CMapObject.php

示例3: testFilter

 public function testFilter()
 {
     $map = ["one" => 1, "two" => 2, "three" => 3, "four" => 4, "five" => 5, "six" => 6, "seven" => 7, "eight" => 8, "nine" => 9, "ten" => 10];
     $map = CMap::filter($map, function ($value) {
         return CMathi::isEven($value);
     });
     $this->assertTrue(CMap::equals($map, ["two" => 2, "four" => 4, "six" => 6, "eight" => 8, "ten" => 10]));
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:8,代码来源:CMapTest.php


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