本文整理汇总了PHP中Arr::insert_after_key方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::insert_after_key方法的具体用法?PHP Arr::insert_after_key怎么用?PHP Arr::insert_after_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::insert_after_key方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: field
/**
* Get Field instance
*
* @param string|null field name or null to fetch an array of all
* @param bool whether to get the fields array or flattened array
* @param bool whether to include tabular form fields in the flattened array
* @return Fieldset_Field|false returns false when field wasn't found
*/
public function field($name = null, $flatten = false, $tabular_form = true)
{
if ($name === null) {
$fields = $this->fields;
if ($flatten) {
foreach ($this->fieldset_children as $fs_name => $fieldset) {
if ($tabular_form or !$fieldset->get_tabular_form()) {
\Arr::insert_after_key($fields, $fieldset->field(null, true), $fs_name);
}
unset($fields[$fs_name]);
}
}
return $fields;
}
if (!array_key_exists($name, $this->fields)) {
if ($flatten) {
foreach ($this->fieldset_children as $fieldset) {
if (($field = $fieldset->field($name)) !== false) {
return $field;
}
}
}
return false;
}
return $this->fields[$name];
}
示例2: test_insert_after_value
/**
* Tests Arr::insert_after_value()
*
* @test
*/
public function test_insert_after_value()
{
$people = array("Jack", "Jill");
$expected = array("Jack", "Humpty", "Jill");
$output = Arr::insert_after_key($people, "Humpty", "Jack");
$this->assertEquals(true, $output);
$this->assertEquals($expected, $people);
}
示例3: test_insert_after_key_that_does_not_exist
/**
* Tests Arr::insert_after_key()
*
* @test
*/
public function test_insert_after_key_that_does_not_exist()
{
$people = array("Jack", "Jill");
$output = Arr::insert_after_key($people, "Humpty", 6);
$this->assertFalse($output);
}
示例4: insert_after
/**
* Insert after a specific key.
*
* @access public
* @return void
*/
public function insert_after($key, $title, $callback, $ukey = null)
{
$this->prepare_insert($callback, $ukey);
\Arr::insert_after_key($this->properties, $title, $key);
$this->properties = \Arr::replace_key($this->properties, array(0 => $ukey));
return $this;
}