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


PHP Arr::search方法代码示例

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


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

示例1: _fromXml

 /**
  * Import XML data
  *
  * @param   string  $string
  * @return  array
  */
 protected function _fromXml($string, $recursive = false)
 {
     // If it forged with 'xml:ns'
     if (!$this->xmlIgnoreNamespaces) {
         static $escape_keys = array();
         if (!$recursive) {
             $escape_keys = array('_xmlns' => 'xmlns');
         }
         if (!$recursive and strpos($string, 'xmlns') !== false and preg_match_all('/(\\<.+?\\>)/s', $string, $matches)) {
             foreach ($matches[1] as $tag) {
                 $escaped_tag = $tag;
                 strpos($tag, 'xmlns=') !== false and $escaped_tag = str_replace('xmlns=', '_xmlns=', $tag);
                 if (preg_match_all('/[\\s\\<\\/]([^\\/\\s\'"]*?:\\S*?)[=\\/\\>\\s]/s', $escaped_tag, $xmlns)) {
                     foreach ($xmlns[1] as $ns) {
                         $escaped = Arr::search($escape_keys, $ns);
                         $escaped or $escape_keys[$escaped = str_replace(':', '_', $ns)] = $ns;
                         $string = str_replace($tag, $escaped_tag = str_replace($ns, $escaped, $escaped_tag), $string);
                         $tag = $escaped_tag;
                     }
                 }
             }
         }
     }
     $_arr = is_string($string) ? simplexml_load_string($string, 'SimpleXMLElement', LIBXML_NOCDATA) : $string;
     $arr = array();
     // Convert all objects SimpleXMLElement to array recursively
     foreach ((array) $_arr as $key => $val) {
         if (!$this->xmlIgnoreNamespaces) {
             $key = Arr::get($escape_keys, $key, $key);
         }
         $arr[$key] = (is_array($val) or is_object($val)) ? $this->_fromXml($val, true) : $val;
     }
     return $arr;
 }
开发者ID:fuelphp,项目名称:common,代码行数:40,代码来源:Format.php

示例2: test_search_multi_array

 /**
  * Tests Arr::search()
  *
  * @test
  */
 public function test_search_multi_array()
 {
     // Multi-dimensional array
     $arr_multi = array('one' => array('test' => 1), 'two' => array('test' => 2), 'three' => array('test' => array('a' => 'a', 'b' => 'b')));
     $expected = 'one';
     $this->assertEquals($expected, Arr::search($arr_multi, array('test' => 1), null, false));
     $expected = null;
     $this->assertEquals($expected, Arr::search($arr_multi, 1, null, false));
     // Multi-dimensional array (recursive)
     $expected = 'one.test';
     $this->assertEquals($expected, Arr::search($arr_multi, 1));
     $expected = 'three.test.b';
     $this->assertEquals($expected, Arr::search($arr_multi, 'b', null, true));
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:19,代码来源:arr.php

示例3: isValidTimezone

 /**
  * is valid timezone.<br>
  * check and return real timezone value.
  * 
  * @param string $timezone check timezone
  * @return string return checked and get timezone value. if found that this is invalid then return null.
  */
 public static function isValidTimezone($timezone)
 {
     \Config::load('timezone', 'timezone');
     $timezone_list = \Config::get('timezone.timezone', array());
     if (array_key_exists($timezone, $timezone_list)) {
         // found in timezone list key. convert to timezone list value.
         $timezone = static::getRealTimezoneValue($timezone);
     } elseif (\Arr::search($timezone_list, $timezone) === null) {
         // not found in the timezone list value. this is not the timezone key and not even timezone value.!
         $timezone = null;
     }
     unset($timezone_list);
     return $timezone;
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:21,代码来源:date.php


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