本文整理汇总了PHP中Arr::to_assoc方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::to_assoc方法的具体用法?PHP Arr::to_assoc怎么用?PHP Arr::to_assoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::to_assoc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_to_assoc_with_odd_number_of_elements
/**
* Tests Arr::to_assoc()
*
* @test
*/
public function test_to_assoc_with_odd_number_of_elements()
{
$arr = array('foo', 'bar', 'baz');
$expected = null;
$this->assertEquals($expected, Arr::to_assoc($arr));
}
示例2: to_assoc
/**
* Converts the current URI segments to an associative array. If
* the URI has an odd number of segments, an empty value will be added.
*
* @param int segment number to start from. default value is the first segment
* @return array the assoc array
*/
public static function to_assoc($start = 1)
{
$segments = array_slice(static::segments(), $start - 1);
count($segments) % 2 and $segments[] = null;
return \Arr::to_assoc($segments);
}
示例3: to_assoc
/**
* Converts the current URI segments to an associative array. If
* the URI has an odd number of segments, null will be returned.
*
* @return array|null the array or null
*/
public static function to_assoc()
{
return \Arr::to_assoc(static::segments());
}
示例4: test_to_assoc_with_odd_number_of_elements
/**
* Tests Arr::to_assoc()
*
* @test
* @expectedException BadMethodCallException
*/
public function test_to_assoc_with_odd_number_of_elements()
{
$arr = array('foo', 'bar', 'baz');
Arr::to_assoc($arr);
}