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


PHP Arr::is_multi方法代码示例

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


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

示例1: add_item

 public function add_item($data = array(), $default = false, $save = true)
 {
     if (\Arr::is_multi($data)) {
         foreach ($data as $default => $item) {
             $this->add_item($item, $default === 'default', false);
         }
     } else {
         $model = \Model_Enum_Item::forge();
         $model->set($data);
         $this->items[] = $model;
         $default === true and $this->default = $model;
     }
     $save === true and $this->save(true);
 }
开发者ID:indigophp,项目名称:indigo-enum,代码行数:14,代码来源:enum.php

示例2: to_csv

 /**
  * To CSV conversion
  *
  * @param mixed $data        	
  * @param mixed $delimiter        	
  * @return string
  */
 public function to_csv($data = null, $delimiter = null)
 {
     // csv format settings
     $newline = \Config::get('format.csv.export.newline', \Config::get('format.csv.newline', "\n"));
     $delimiter or $delimiter = \Config::get('format.csv.export.delimiter', \Config::get('format.csv.delimiter', ','));
     $enclosure = \Config::get('format.csv.export.enclosure', \Config::get('format.csv.enclosure', '"'));
     $escape = \Config::get('format.csv.export.escape', \Config::get('format.csv.escape', '"'));
     // escape function
     $escaper = function ($items) use($enclosure, $escape) {
         return array_map(function ($item) use($enclosure, $escape) {
             return str_replace($enclosure, $escape . $enclosure, $item);
         }, $items);
     };
     if ($data === null) {
         $data = $this->_data;
     }
     if (is_object($data) and !$data instanceof \Iterator) {
         $data = $this->to_array($data);
     }
     // Multi-dimensional array
     if (is_array($data) and \Arr::is_multi($data)) {
         $data = array_values($data);
         if (\Arr::is_assoc($data[0])) {
             $headings = array_keys($data[0]);
         } else {
             $headings = array_shift($data);
         }
     } else {
         $headings = array_keys((array) $data);
         $data = array($data);
     }
     $output = $enclosure . implode($enclosure . $delimiter . $enclosure, $escaper($headings)) . $enclosure . $newline;
     foreach ($data as $row) {
         $output .= $enclosure . implode($enclosure . $delimiter . $enclosure, $escaper((array) $row)) . $enclosure . $newline;
     }
     return rtrim($output, $newline);
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:44,代码来源:format.php

示例3: hookGetMultisiteTables

 /**
  * hook plugin to get multisite tables names.<br>
  * this will get module's tables that need to be copy while create new site.<br>
  * attention! you must call this method everytime when you want to access multisite tables list.
  * 
  * @todo [fuelstart][multisite][plug] get module's multisite tables plug.
  */
 public function hookGetMultisiteTables()
 {
     $plugin = new \Library\Plugins();
     if ($plugin->hasFilter('SitesGetModulesMultisiteTables') !== false) {
         $plugin->doFilter('SitesGetModulesMultisiteTables');
         if (is_array($plugin->original_data) && !empty($plugin->original_data)) {
             foreach ($plugin->original_data as $table) {
                 if (!empty($table)) {
                     if (is_array($table) && !\Arr::is_multi($table)) {
                         $this->multisite_tables = array_merge($this->multisite_tables, $table);
                     } elseif (is_string($table)) {
                         $this->multisite_tables = array_merge($this->multisite_tables, [$table]);
                     }
                 }
             }
             unset($each_cfg);
             $this->multisite_tables = \Arr::unique($this->multisite_tables);
         }
     }
     unset($plugin);
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:28,代码来源:sites.php

示例4: test_multidimensional_array

 /**
  * Tests Arr::is_multi()
  *
  * @test
  */
 public function test_multidimensional_array()
 {
     // Single array
     $arr_single = array('one' => 1, 'two' => 2);
     $this->assertFalse(Arr::is_multi($arr_single));
     // Multi-dimensional array
     $arr_multi = array('one' => array('test' => 1), 'two' => array('test' => 2), 'three' => array('test' => 3));
     $this->assertTrue(Arr::is_multi($arr_multi));
     // Multi-dimensional array (not all elements are arrays)
     $arr_multi_strange = array('one' => array('test' => 1), 'two' => array('test' => 2), 'three' => 3);
     $this->assertTrue(Arr::is_multi($arr_multi_strange, false));
     $this->assertFalse(Arr::is_multi($arr_multi_strange, true));
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:18,代码来源:arr.php

示例5: average

 /**
  * get the average of the items
  *
  * @param array[array]      $array
  * @param string            $key
  */
 public static function average($array, $key = null)
 {
     if (!is_array($array)) {
         throw new \InvalidArgumentException('Arr::average - first argunent has to be an array.');
     }
     if (is_string($key) && Arr::is_multi($array)) {
         $array = Arr::pick($key, $array);
     }
     return static::sum($array) / count($array);
 }
开发者ID:cineman,项目名称:workbench,代码行数:16,代码来源:Arr.php

示例6: to_csv

 /**
  * To CSV conversion
  *
  * @param   mixed   $data
  * @param   mixed   $separator
  * @return  string
  */
 public function to_csv($data = null, $separator = ',')
 {
     if ($data === null) {
         $data = $this->_data;
     }
     if (is_object($data) and !$data instanceof \Iterator) {
         $data = $this->to_array($data);
     }
     // Multi-dimensional array
     if (is_array($data) and \Arr::is_multi($data)) {
         $data = array_values($data);
         if (\Arr::is_assoc($data[0])) {
             $headings = array_keys($data[0]);
         } else {
             $headings = array_shift($data);
         }
     } else {
         $headings = array_keys((array) $data);
         $data = array($data);
     }
     $output = "\"" . implode('"' . $separator . '"', $headings) . "\"\n";
     foreach ($data as &$row) {
         $output .= '"' . implode('"' . $separator . '"', (array) $row) . "\"\n";
     }
     return rtrim($output, "\n");
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:33,代码来源:format.php

示例7: to_csv

 /**
  * To CSV conversion
  *
  * @param   mixed   $data
  * @param   mixed   $delimiter
  * @param   mixed   $enclose_numbers
  * @param   array   $headings  Custom headings to use
  * @return  string
  */
 public function to_csv($data = null, $delimiter = null, $enclose_numbers = null, array $headings = array())
 {
     // csv format settings
     $newline = \Config::get('format.csv.newline', \Config::get('format.csv.export.newline', "\n"));
     $delimiter or $delimiter = \Config::get('format.csv.delimiter', \Config::get('format.csv.export.delimiter', ','));
     $enclosure = \Config::get('format.csv.enclosure', \Config::get('format.csv.export.enclosure', '"'));
     $escape = \Config::get('format.csv.escape', \Config::get('format.csv.export.escape', '\\'));
     is_null($enclose_numbers) and $enclose_numbers = \Config::get('format.csv.delimit_numbers', true);
     // escape, delimit and enclose function
     $escaper = function ($items, $enclose_numbers) use($enclosure, $escape, $delimiter) {
         return implode($delimiter, array_map(function ($item) use($enclosure, $escape, $delimiter, $enclose_numbers) {
             if (!is_numeric($item) or $enclose_numbers) {
                 $item = $enclosure . str_replace($enclosure, $escape . $enclosure, $item) . $enclosure;
             }
             return $item;
         }, $items));
     };
     if ($data === null) {
         $data = $this->_data;
     }
     if (is_object($data) and !$data instanceof \Iterator) {
         $data = $this->to_array($data);
     }
     // Multi-dimensional array
     if (empty($headings)) {
         if (is_array($data) and \Arr::is_multi($data)) {
             $data = array_values($data);
             if (\Arr::is_assoc($data[0])) {
                 $headings = array_keys($data[0]);
             } else {
                 $headings = array_shift($data);
             }
         } else {
             $headings = array_keys((array) $data);
             $data = array($data);
         }
     }
     $output = $escaper($headings, true) . $newline;
     foreach ($data as $row) {
         $output .= $escaper($row, $enclose_numbers) . $newline;
     }
     return rtrim($output, $newline);
 }
开发者ID:takawasitobi,项目名称:pembit,代码行数:52,代码来源:format.php

示例8: buildQueryOptions

 protected static function buildQueryOptions($query, $options)
 {
     foreach ($options as $key => $value) {
         switch ($key) {
             case 'select':
                 $query = isset($options['join']) ? static::buildSelect($query, $value, true) : static::buildSelect($query, $value);
                 break;
             case 'where':
                 if (is_array($value) and count($value) > 0) {
                     if (\Arr::is_multi($value, true) and \Arr::is_assoc($value)) {
                         if (\Arr::get($value, 'ROOT') !== null) {
                             $count = count($value['ROOT']);
                             if ($count == 3) {
                                 $query->where($value['ROOT'][0], $value['ROOT'][1], $value['ROOT'][2]);
                             }
                             if ($count == 2) {
                                 $query->where($value['ROOT'][0], $value['ROOT'][1]);
                             }
                         }
                         if (\Arr::get($value, 'AND') !== null) {
                             foreach ($value['AND'] as $item) {
                                 $count = count($item);
                                 if ($count == 3) {
                                     $query->and_where($item[0], $item[1], $item[2]);
                                 }
                                 if ($count == 2) {
                                     $query->and_where($item[0], $item[1]);
                                 }
                             }
                         }
                         if (\Arr::get($value, 'OR') !== null) {
                             foreach ($value['OR'] as $item) {
                                 $count = count($item);
                                 if ($count == 3) {
                                     $query->or_where($item[0], $item[1], $item[2]);
                                 }
                                 if ($count == 2) {
                                     $query->or_where($item[0], $item[1]);
                                 }
                             }
                         }
                     } else {
                         foreach ($value as $k => $v) {
                             if (is_array($v)) {
                                 $count = count($v);
                                 switch ($count) {
                                     case 2:
                                         $query->where($v[0], $v[1]);
                                         break;
                                     case 3:
                                         $query->where($v[0], $v[1], $v[2]);
                                         break;
                                     default:
                                         break;
                                 }
                             } else {
                                 $query->where($k, $v);
                             }
                         }
                     }
                 }
                 break;
             case 'join':
                 if (is_array($value) and $value) {
                     foreach ($value as $join) {
                         if (isset($join['select'])) {
                             (is_array($join['select']) and $join['select']) ? $query->select_array($join['select']) : $query->select($join['select']);
                         }
                         isset($join['type']) ? $query->join($join['table'], $join['type']) : $query->join($join['table']);
                         $query->on($join['on'][0], $join['on'][1], $join['on'][2]);
                     }
                 }
                 break;
             case 'limit':
                 if (is_array($value) and count($value) > 0) {
                     if (count($value) == 1) {
                         $query->limit($value[0]);
                     }
                     if (count($value) == 2) {
                         $query->limit($value[0]);
                         $query->offset($value[1]);
                     }
                 } else {
                     $query->limit($value);
                 }
                 break;
             case 'order':
                 if (is_array($value) and count($value) > 0) {
                     while (list($key, $direction) = each($value)) {
                         is_int($key) ? $query->order_by($direction) : $query->order_by($key, $direction);
                     }
                 } else {
                     $query->order_by(\DB::expr($value));
                 }
                 break;
             case 'group':
                 if (is_array($value) and count($value) > 0) {
                     foreach ($value as $field) {
                         $query->group_by($field);
                     }
//.........这里部分代码省略.........
开发者ID:khoapossible,项目名称:vision_system,代码行数:101,代码来源:advanced.php

示例9: set_where

 protected static function set_where(\Orm\Query $query, $params = array())
 {
     if (!$params) {
         return $query;
     }
     if (!is_array($params)) {
         $params = (array) $params;
     }
     if (!\Arr::is_multi($params)) {
         return static::set_where4not_multi($query, $params);
     }
     if (count($params) == 3 && !is_array($params[0]) && in_array(strToLower($params[2]), array('in', '<', '>', '<=', '>='))) {
         return static::set_where4not_multi($query, $params);
     }
     foreach ($params as $param) {
         $query = static::set_where4not_multi($query, $param);
     }
     return $query;
 }
开发者ID:uzura8,项目名称:flockbird,代码行数:19,代码来源:model.php


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