本文整理匯總了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;
}