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


PHP Arr::is_array方法代码示例

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


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

示例1: set

 /**
  * Set routes and nested resources based on the models
  *
  * @param string|arrau $model the name of the resource or an array of names
  * @param array $options array of options - see the usage description
  * @param string $parent the name of the parent route
  */
 public static function set($name, array $options = array(), $parent = NULL)
 {
     if (Arr::is_array($name)) {
         $resources = array();
         foreach ($name as $resource_name) {
             $resources[] = Resource::set($resource_name, $options, $parent);
         }
         return $resources;
     }
     $resource = new Resource($name, $options, $parent);
     return Resource::$_resources[$resource->name()] = $resource;
 }
开发者ID:openbuildings,项目名称:jam-resource,代码行数:19,代码来源:Resource.php

示例2: get_product

 public function get_product($id, $qty, array $options = array())
 {
     // get only active products & return correct fields names
     $this->clear()->select(array('in_stock', 'qty'))->where('active', '=', 1);
     if (Arr::is_array($id)) {
         $result = $this->where($this->primary_key(), 'IN', $id)->find_all();
         // TODO: ADD in_stock check
     } else {
         $result = $this->where($this->primary_key(), '=', $id)->and_where('in_stock', '>=', $qty)->find();
     }
     if ($result->loaded()) {
         return $result->as_array();
     } else {
         // TODO:
         throw new Kohana_Exception(__('Old data =\\ '));
     }
 }
开发者ID:szymon7907,项目名称:kohana-shopping-cart,代码行数:17,代码来源:Product.php

示例3: path

 /**
  * Gets a value from an array using a dot separated path.
  *
  *     // Get the value of $array['foo']['bar']
  *     $value = Arr::path($array, 'foo.bar');
  *
  * Using a wildcard "*" will search intermediate arrays and return an array.
  *
  *     // Get the values of "color" in theme
  *     $colors = Arr::path($array, 'theme.*.color');
  *
  *     // Using an array of keys
  *     $colors = Arr::path($array, array('theme', '*', 'color'));
  *
  * @param   array   $array      array to search
  * @param   mixed   $path       key path string (delimiter separated) or array of keys
  * @param   mixed   $default    default value if the path is not set
  * @param   string  $delimiter  key path delimiter
  * @return  mixed
  */
 public static function path($array, $path, $default = NULL, $delimiter = NULL)
 {
     if (!Arr::is_array($array)) {
         // This is not an array!
         return $default;
     }
     if (is_array($path)) {
         // The path has already been separated into keys
         $keys = $path;
     } else {
         if (array_key_exists($path, $array)) {
             // No need to do extra processing
             return $array[$path];
         }
         if ($delimiter === NULL) {
             // Use the default delimiter
             $delimiter = Arr::$delimiter;
         }
         // Remove starting delimiters and spaces
         $path = ltrim($path, "{$delimiter} ");
         // Remove ending delimiters, spaces, and wildcards
         $path = rtrim($path, "{$delimiter} *");
         // Split the keys by delimiter
         $keys = explode($delimiter, $path);
     }
     do {
         $key = array_shift($keys);
         if (ctype_digit($key)) {
             // Make the key an integer
             $key = (int) $key;
         }
         if (isset($array[$key])) {
             if ($keys) {
                 if (Arr::is_array($array[$key])) {
                     // Dig down into the next part of the path
                     $array = $array[$key];
                 } else {
                     // Unable to dig deeper
                     break;
                 }
             } else {
                 // Found the path requested
                 return $array[$key];
             }
         } elseif ($key === '*') {
             // Handle wildcards
             $values = array();
             foreach ($array as $arr) {
                 if ($value = Arr::path($arr, implode('.', $keys))) {
                     $values[] = $value;
                 }
             }
             if ($values) {
                 // Found the values requested
                 return $values;
             } else {
                 // Unable to dig deeper
                 break;
             }
         } else {
             // Unable to dig deeper
             break;
         }
     } while ($keys);
     // Unable to find the value requested
     return $default;
 }
开发者ID:RobBickel,项目名称:las,代码行数:87,代码来源:Arr.php

示例4: test_is_array

 /**
  * Tests Arr::is_array()
  *
  * @test
  * @dataProvider provider_is_array
  * @param mixed   $value     Value to check
  * @param boolean $expected  Is $value an array?
  */
 public function test_is_array($array, $expected)
 {
     $this->assertSame($expected, Arr::is_array($array));
 }
开发者ID:sittercity,项目名称:core,代码行数:12,代码来源:ArrTest.php

示例5: implode

</dd>
<dt class="petfinderBioLabel">Status</dt><dd class="petfinderBioData"><?php 
echo $info['status'];
?>
</dd>
<dt class="petfinderBioLabel">Age</dt><dd class="petfinderBioData"><?php 
echo $info['age'];
?>
</dd>
<dt class="petfinderBioLabel">Sex</dt><dd class="petfinderBioData"><?php 
echo $info['sex'];
?>
</dd>
<dt class="petfinderBioLabel">Breed</dt><dd class="petfinderBioData">
<?php 
if (Arr::is_array($info['breed'])) {
    echo implode(' and ', $info['breed']);
} else {
    echo $info['breed'];
}
?>
</dd>
<?php 
if (isset($info['options'])) {
    ?>
	<dt class="petfinderBioLabel">Details</dt><dd class="petfinderBioData">
	<ul>
<?php 
    $option_count = count($info['options']);
    for ($i = 0; $i < $option_count; $i++) {
        echo '<li>' . $info['options'][$i] . '</li>';
开发者ID:randomecho,项目名称:petfinder-via-kohana,代码行数:31,代码来源:petfinder_single.php

示例6: set_column_options_using_matching_rules

 /**
  * 
  * @param array $column_params
  * @param array $rule_data
  * @return array
  */
 private function set_column_options_using_matching_rules(array $column_params, array $rule_data)
 {
     foreach ($rule_data as $data_key => $value) {
         if (Arr::is_array($value)) {
             $rule_data[$data_key] = $this->set_column_options_using_matching_rules($column_params, $value);
         } else {
             if (is_string($value)) {
                 if (UTF8::substr($value, 0, 1) == ':') {
                     $key = str_replace(':', '', $value);
                     if (Arr::get($column_params, $key)) {
                         $rule_data[$data_key] = $column_params[$key];
                     }
                 }
             }
         }
     }
     return $rule_data;
 }
开发者ID:bobpps,项目名称:kohana-alive-cms,代码行数:24,代码来源:structure.php

示例7: action_delete_table

 public function action_delete_table()
 {
     try {
         $tables = $this->request->post('tables');
         if (Arr::is_array($tables)) {
             foreach ($tables as $alias) {
                 $table = Cms_Structure::factory($alias);
                 if ($table != NULL) {
                     unlink($table->get_file_name());
                 }
             }
         }
         $this->add_result_data('urlToRedirect', Cms_Urlmanager::get_tools_url('structure'));
     } catch (Exception $exc) {
         $this->set_error($exc->getMessage());
     }
 }
开发者ID:bobpps,项目名称:kohana-alive-cms,代码行数:17,代码来源:ajax.php

示例8: set

 public function set($id, $qty = 1, array $options = array())
 {
     if (Arr::is_array($id)) {
         $products = $this->_get_product(Arr::pluck($id, 'id'), Arr::pluck($id, 'qty'), Arr::pluck($id, 'options'));
         // $products = $this->_get_product($id, $qty, $options);
         $products = $this->_get_product($id, $qty, $options);
     } else {
         $qty = max(1, $qty);
         $products[0] = $this->_get_product($id, $qty, $options);
     }
     foreach ($products as $product) {
         $product['options'] = Arr::get($product, 'options', array());
         // Composite identifier
         $mix_id = $this->_get_mix_id($product['id'], $product['options']);
         if (isset($this->_content['products'][$mix_id])) {
             if ($product['qty'] >= $this->_content['products'][$mix_id]['qty'] + $qty) {
                 $this->_content['products'][$mix_id]['qty'] += $qty;
             } else {
                 throw new Kohana_Exception('In stock only :qty items', array(':qty' => $product['qty']));
                 // return FALSE;
             }
         } else {
             //$product['qty'] = $qty;
             $this->_content['products'][$mix_id] = $product;
         }
     }
     return $this->_save();
 }
开发者ID:szymon7907,项目名称:kohana-shopping-cart,代码行数:28,代码来源:Cart.php


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