本文整理汇总了PHP中Arr::prepend方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::prepend方法的具体用法?PHP Arr::prepend怎么用?PHP Arr::prepend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::prepend方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Add one or multiple routes
*
* @param string
* @param string|array|Route either the translation for $path, an array for verb routing or an instance of Route
* @param bool whether to prepend the route(s) to the routes array
*/
public static function add($path, $options = null, $prepend = false, $case_sensitive = null)
{
if (is_array($path)) {
// Reverse to keep correct order in prepending
$prepend and $path = array_reverse($path, true);
foreach ($path as $p => $t) {
static::add($p, $t, $prepend);
}
return;
} elseif ($options instanceof Route) {
static::$routes[$path] = $options;
return;
}
$name = $path;
if (is_array($options) and array_key_exists('name', $options)) {
$name = $options['name'];
unset($options['name']);
if (count($options) == 1 and !is_array($options[0])) {
$options = $options[0];
}
}
if ($prepend) {
\Arr::prepend(static::$routes, $name, new \Route($path, $options, $case_sensitive));
return;
}
static::$routes[$name] = new \Route($path, $options, $case_sensitive);
}
示例2: prepend
/**
* Push an item onto the beginning of the collection.
*
* @param mixed $value
* @param mixed $key
* @return $this
*/
public function prepend($value, $key = null)
{
$this->items = Arr::prepend($this->items, $value, $key);
return $this;
}
示例3: test_prepend_array
/**
* Tests Arr::prepend()
*
* @test
*/
public function test_prepend_array()
{
$arr = array('two' => 2, 'three' => 3);
$expected = array('one' => 1, 'two' => 2, 'three' => 3);
Arr::prepend($arr, array('one' => 1));
$this->assertEquals($expected, $arr);
}
示例4: prepend
/**
* Prepend an user row.
*
* @access public
* @param mixed $title
* @param mixed $callback
* @return void
*/
public function prepend($title, $callback, $ukey = null)
{
$this->prepare_insert($callback, $ukey);
\Arr::prepend($this->properties, $ukey, $title);
return $this;
}