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