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


PHP Arr::unshift方法代码示例

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


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

示例1: test_unshift

 public function test_unshift()
 {
     $array = array('two' => 'bar');
     // The "one" key should be prepended to the array
     $expect = array('one' => 'foo') + $array;
     $this->assert_equal(Arr::unshift($array, 'one', 'foo'), $expect);
 }
开发者ID:banks,项目名称:unittest,代码行数:7,代码来源:arr.php

示例2: input

 public function input($name, $value, array $attr = NULL)
 {
     $model = Sprig::factory($this->model);
     $choices = $model->select_list($model->pk());
     if ($this->empty) {
         Arr::unshift($choices, '', '-- ' . __('None'));
     }
     return Form::select($name, $choices, $this->verbose($value), $attr);
 }
开发者ID:bosoy83,项目名称:progtest,代码行数:9,代码来源:belongsto.php

示例3: __construct

 public function __construct(array $options = NULL)
 {
     parent::__construct($options);
     if ($this->empty or $this->prompt) {
         Arr::unshift($this->codes, '', $this->prompt);
     }
     if (!$this->choices) {
         $this->choices = $this->codes;
     }
 }
开发者ID:bosoy83,项目名称:progtest,代码行数:10,代码来源:country.php

示例4: __construct

 /**
  * Load the default column names
  *
  * @param   mixed  $id  Parameter for find or object to load [Optional]
  * @uses    Arr::unshift
  */
 public function __construct($id = NULL)
 {
     if (empty($this->_sorting)) {
         $this->_sorting = array($this->scope_column => 'ASC', $this->left_column => 'ASC');
     } else {
         $this->_sorting = Arr::unshift($this->_sorting, $this->left_column, 'ASC');
         $this->_sorting = Arr::unshift($this->_sorting, $this->scope_column, 'ASC');
     }
     parent::__construct($id);
 }
开发者ID:ultimateprogramer,项目名称:cms,代码行数:16,代码来源:mptt.php

示例5: input_create

 /**
  * Input for create item
  * @return string Form::input
  */
 public function input_create($value)
 {
     $id = $value->id;
     $field = isset($this->item['field']) ? $this->item['field'] : 'name';
     $values_model = $value->clear()->find_all()->as_array($field);
     $values = array();
     foreach ($values_model as $value) {
         $values[$value->id] = $value->{$field};
     }
     if (!$this->item['notnull']) {
         Arr::unshift($values, 0, '');
     }
     return Form::select($this->item['name'], $values, $id);
 }
开发者ID:raku,项目名称:MorCMS,代码行数:18,代码来源:hasmany.php

示例6: input

 /**
  * Create input for options
  * @param mixed $value
  * @return string html 
  */
 protected function input($value)
 {
     $options = array();
     // if values is exists use like key value pair (for int type item in db)
     if (isset($this->item['values']) and $this->item['values'] != null) {
         foreach ($this->item['values'] as $option) {
             $options[$option] = $option;
         }
     } else {
         $columns = $this->model->table_columns();
         $options_temp = $columns[$this->get_name()]['options'];
         foreach ($options_temp as $option) {
             $options[$option] = $option;
         }
     }
     if (!isset($this->item['notnull']) or !$this->item['notnull']) {
         Arr::unshift($options, '', '');
     }
     return Form::select($this->get_name(), $options, $value);
 }
开发者ID:raku,项目名称:MorCMS,代码行数:25,代码来源:options.php

示例7: radios

 /**
  * Radios select, bootstrap style
  * @param  string $name
  * @param  array  $options
  * @param  array  $attributes
  * @return string
  */
 public function radios($name, array $options = array(), array $attributes = array())
 {
     $attributes = $this->default_attributes($name, $attributes);
     if (!isset($options['choices'])) {
         throw new Kohana_Exception('Radios tag widget requires a \'choices\' option');
     }
     $choices = Jam_Form::list_choices($options['choices']);
     if ($blank = Arr::get($options, 'include_blank')) {
         Arr::unshift($choices, '', $blank === TRUE ? __(" -- Select -- ") : $blank);
     }
     $radios = array();
     foreach ($choices as $key => $title) {
         $radio = $this->radio($name, array('value' => $key), array('id' => $attributes['id'] . '_' . $key));
         $radios[] = new Builder_Html('label', array('class' => 'radio'), $radio . $title);
     }
     return '<div ' . HTML::attributes($attributes) . '>' . join("\n", $radios) . '</div>';
 }
开发者ID:openbuildings,项目名称:jam-tart,代码行数:24,代码来源:General.php

示例8: test_unshift

 /**
  * Tests Arr::unshift()
  *
  * @test
  * @dataProvider provider_unshift
  * @param array $array
  * @param string $key
  * @param mixed $value
  */
 public function test_unshift(array $array, $key, $value)
 {
     $original = $array;
     Arr::unshift($array, $key, $value);
     $this->assertNotSame($original, $array);
     $this->assertSame(count($original) + 1, count($array));
     $this->assertArrayHasKey($key, $array);
     $this->assertSame($value, reset($array));
     $this->assertSame(key($array), $key);
 }
开发者ID:sittercity,项目名称:core,代码行数:19,代码来源:ArrTest.php

示例9: input_filter

 /**
  * input for filter
  * @param string $value
  * @return string form::select 
  */
 public function input_filter($value)
 {
     if (!is_object($value)) {
         $object = ORM::factory($this->item['name']);
         $field_value = $value;
     } else {
         $object = $value;
         $field_value = 0;
     }
     $field = isset($this->item['field']) ? $this->item['field'] : 'name';
     $values_model = $object->find_all()->as_array($field);
     $values = array();
     foreach ($values_model as $value) {
         $values[$value->id] = $value->{$field};
     }
     if (!$this->item['notnull']) {
         Arr::unshift($values, 0, '');
     }
     return Form::select($this->item['name'], $values, $field_value);
 }
开发者ID:raku,项目名称:MorCMS,代码行数:25,代码来源:belongsto.php

示例10:

if (!empty($errors['name'])) {
    echo '<span class="help-inline">' . $errors['name'] . '</span>';
}
?>
				</div>
			</div>
			<div class="clearfix<?php 
if (!empty($errors['cat'])) {
    echo ' error';
}
?>
">
				<label>Category: </label>
				<div class="input">
					<?php 
Arr::unshift($categories, '', 'Please select&hellip;');
echo Form::select('category_id', $categories);
?>
					<?php 
if (!empty($errors['cat'])) {
    echo '<span class="help-inline">' . $errors['cat'] . '</span>';
}
?>
				</div>
			</div>
			<div class="clearfix">
				<label>&pound;Guide: </label>
				<div class="input">
					<div class="input-prepend">
						<span class="add-on">&pound;</span>
						<input name="price" value="<?php 
开发者ID:Thanandar,项目名称:GiftCircle,代码行数:31,代码来源:add.php

示例11: find_for_select

 /**
  * Return array for html <select> element
  *
  * Example:
  *
  *     $arr_options = ORM::factory('Model_Name')
  *         ->order_by('title');
  *         ->find_for_select('id', 'title', array('none', 'Select a value'));
  *
  *     echo Form::select('id', $arr_options);
  *
  * @param $key value      for option tag
  * @param $val body       for option tag
  * @param array $unshift add an empty value to the start of a select list
  *                        first element of $unshift - value for first option tag
  *                        second element of $unshift - body for first option tag
  * @return array
  */
 public function find_for_select($key, $val, array $unshift = [])
 {
     $array = $this->find_all()->as_array($key, $val);
     if (isset($unshift[0]) and isset($unshift[1])) {
         Arr::unshift($array, $unshift[0], $unshift[1]);
     }
     return $array;
 }
开发者ID:eok8177,项目名称:shopCMS,代码行数:26,代码来源:ORM.php

示例12: add_geo_marker

 /**
  * Create marker object using geocoding
  *
  * @todo   Add $options processing
  * @param  array $info
  * @param  array $options
  * @return void
  */
 private function add_geo_marker($info, $options)
 {
     $id = Arr::get($info, 'id', substr(md5(rand(0, 1000)), 0, 4));
     $info = Arr::unshift($info, 'id', $id);
     $this->geo_markers[] = $info;
 }
开发者ID:smgladkovskiy,项目名称:kohana-yamaps,代码行数:14,代码来源:core.php

示例13: select

 /**
  * HTML input select field
  * available options
  * 	- choices - this can be Jam_Query_Builder_Collection or a simple array
  * 	- include_blank - bool|string - include an empty option
  *
  * @param string $name       the name of the Jam_Model attribute
  * @param array  $options    set the options of the select with 'choices' and 'include_blank'
  * @param array  $attributes HTML attributes for the field
  * @return string
  */
 public function select($name, array $options = array(), array $attributes = array())
 {
     $attributes = $this->default_attributes($name, $attributes);
     if (!isset($options['choices'])) {
         throw new Kohana_Exception("Select tag widget requires a 'choices' option");
     }
     $choices = Jam_Form::list_choices($options['choices']);
     if ($blank = Arr::get($options, 'include_blank')) {
         Arr::unshift($choices, '', $blank === TRUE ? " -- Select -- " : $blank);
     }
     $selected = Jam_Form::list_id($this->object()->{$name});
     return Form::select($attributes['name'], $choices, $selected, $attributes);
 }
开发者ID:Konro1,项目名称:pms,代码行数:24,代码来源:General.php

示例14:

<h1>ACL Debugger</h1>

<p>Something seem off? Check the <?php 
echo HTML::anchor($matrix, 'full matrix');
?>
.</p>

<?php 
echo Form::open();
?>
<p>
	Is <?php 
echo Form::select('role', Arr::unshift($roles, '', '-- any'), $role);
?>
	allowed to <?php 
echo Form::select('action', Arr::unshift($actions, '', '-- any'), $action);
?>
	a <?php 
echo Form::select('resource', Arr::unshift($resources, '', '-- any'), $resource);
?>
	?
	<button type="submit">Test It!</button>
</p>
<?php 
echo Form::close();
?>

<?php 
if (is_bool($allowed)) {
    include Kohana::find_file('views/demo', 'bonafide/acl/check');
}
开发者ID:bosoy83,项目名称:progtest,代码行数:31,代码来源:debug.php

示例15: _get_unshift

 /**
  * Add first element for select
  * @param $items
  * @param array $unshift
  * @return mixed
  */
 private function _get_unshift($items, array $unshift)
 {
     if (isset($unshift[0]) and isset($unshift[1])) {
         $std_class = new stdClass();
         $std_class->id = $unshift[0];
         $std_class->{$this->_display_field} = $unshift[1];
         $std_class->level = 0;
         Arr::unshift($items, $unshift[0], $std_class);
     }
     return $items;
 }
开发者ID:eok8177,项目名称:shopCMS,代码行数:17,代码来源:Tree.php


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