本文整理汇总了PHP中Arr::insert_before_key方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::insert_before_key方法的具体用法?PHP Arr::insert_before_key怎么用?PHP Arr::insert_before_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::insert_before_key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_before
/**
* Add a new Fieldset_Field before an existing field in a Fieldset
*
* @param string $name
* @param string $label
* @param array $attributes
* @param array $rules
* @param string $fieldname fieldname before which the new field is inserted in the fieldset
* @return Fieldset_Field
*/
public function add_before($name, $label = '', array $attributes = array(), array $rules = array(), $fieldname = null)
{
$field = $this->add($name, $label, $attributes, $rules);
// Remove from tail and reinsert at correct location
unset($this->fields[$field->name]);
if (!\Arr::insert_before_key($this->fields, array($field->name => $field), $fieldname, true)) {
throw new \RuntimeException('Field "' . $fieldname . '" does not exist in this Fieldset. Field "' . $name . '" can not be added.');
}
return $field;
}
示例2: insert_before
/**
* Insert before a specific key.
*
* @access public
* @return void
*/
public function insert_before($key, $title, $callback, $ukey = null)
{
$this->prepare_insert($callback, $ukey);
\Arr::insert_before_key($this->properties, $title, $key);
$this->properties = \Arr::replace_key($this->properties, array(0 => $ukey));
return $this;
}