當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CMap::valueByPath方法代碼示例

本文整理匯總了PHP中CMap::valueByPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP CMap::valueByPath方法的具體用法?PHP CMap::valueByPath怎麽用?PHP CMap::valueByPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CMap的用法示例。


在下文中一共展示了CMap::valueByPath方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSetValueByPath

 public function testSetValueByPath()
 {
     $map = ["one" => "a", "two" => ["one" => "a", "two" => ["one" => "a", "two" => "b", "three" => "c"]]];
     CMap::setValueByPath($map, "one", "d");
     CMap::setValueByPath($map, "two.one", "e");
     CMap::setValueByPath($map, "two.two.one", "f");
     CMap::setValueByPath($map, "two.two.two", "g");
     CMap::setValueByPath($map, "two.two.three", "h");
     $this->assertTrue(CMap::valueByPath($map, "one") === "d");
     $this->assertTrue(CMap::equals(CMap::valueByPath($map, "two"), ["one" => "e", "two" => ["one" => "f", "two" => "g", "three" => "h"]]));
     $this->assertTrue(CMap::valueByPath($map, "two.one") === "e");
     $this->assertTrue(CMap::equals(CMap::valueByPath($map, "two.two"), ["one" => "f", "two" => "g", "three" => "h"]));
     $this->assertTrue(CMap::valueByPath($map, "two.two.one") === "f");
     $this->assertTrue(CMap::valueByPath($map, "two.two.two") === "g");
     $this->assertTrue(CMap::valueByPath($map, "two.two.three") === "h");
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:16,代碼來源:CMapTest.php

示例2: valueByPath

 /**
  * From a map, returns the value found by a specified key path.
  *
  * @param  string $path The key path by which the value is to be found, e.g. "level1key.level2key".
  *
  * @return mixed The value found by the key path.
  */
 public function valueByPath($path)
 {
     return CMap::valueByPath($this->m_map, $path);
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:11,代碼來源:CMapObject.php

示例3: option

 /**
  * Returns the value of the application's configuration option specified by a global path.
  *
  * @param  string $path The global path to the option.
  *
  * @return mixed The option's value.
  */
 public static function option($path)
 {
     assert('is_cstring($path)', vs(isset($this), get_defined_vars()));
     $value = CMap::valueByPath(self::$ms_config, $path);
     return is_bool($value) ? $value : oop_x($value);
 }
開發者ID:nunodotferreira,項目名稱:Phred,代碼行數:13,代碼來源:CConfiguration.php


注:本文中的CMap::valueByPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。