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


PHP CMap::findScalar方法代码示例

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


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

示例1: findScalar

 /**
  * Determines if a map contains a specified scalar value.
  *
  * If a map only contains values of scalar types i.e. `int`, `float`, `bool`, `string` (ASCII only), or `null`,
  * this method allows for faster searches compared to `find` method. In case of `string` type, the search is
  * case-sensitive.
  *
  * The `find` method would be of better service in searching for Unicode strings (the default comparator used by
  * `find` method is Unicode-aware) and it was made flexible for you to be able to set your own comparison rules,
  * such as making the search case-insensitive for any kind of strings.
  *
  * @param  mixed $whatValue The searched value.
  * @param  reference $foundUnderKey **OPTIONAL. OUTPUT.** If a value has been found after the method was called
  * with this parameter provided, the parameter's value is being the first key under which the value was seen. If
  * the key is a string, its output type is `CUStringObject`.
  *
  * @return bool `true` if such value was found in the map, `false` otherwise.
  *
  * @link   #method_find find
  */
 public function findScalar($whatValue, &$foundUnderKey = null)
 {
     $found = CMap::findScalar($this->m_map, $whatValue, $foundUnderKey);
     return $found;
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:25,代码来源:CMapObject.php

示例2: testFindScalar

 public function testFindScalar()
 {
     $map = ["one" => "a", "two" => "b", "three" => "c", "four" => "d", "five" => "e"];
     $found = CMap::findScalar($map, "c");
     $this->assertTrue($found);
     $foundUnderKey;
     $found = CMap::findScalar($map, "d", $foundUnderKey);
     $this->assertTrue($found);
     $this->assertTrue($foundUnderKey === "four");
     $found = CMap::findScalar($map, "C");
     $this->assertFalse($found);
     $found = CMap::findScalar($map, "f");
     $this->assertFalse($found);
     // Special case.
     $map = CMap::make();
     $found = CMap::findScalar($map, "a");
     $this->assertFalse($found);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:18,代码来源:CMapTest.php


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