本文整理汇总了PHP中Joomla\Utilities\ArrayHelper::pivot方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::pivot方法的具体用法?PHP ArrayHelper::pivot怎么用?PHP ArrayHelper::pivot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joomla\Utilities\ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper::pivot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pivot
/**
* Pivots an array to create a reverse lookup of an array of scalars, arrays or objects.
*
* @param array $source The source array.
* @param string $key Where the elements of the source array are objects or arrays, the key to pivot on.
*
* @return array An array of arrays pivoted either on the value of the keys, or an individual key of an object or array.
*
* @since 11.3
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::pivot instead
*/
public static function pivot($source, $key = null)
{
$result = array();
if (is_array($source)) {
$result = ArrayHelper::pivot($source, $key);
} else {
JLog::add('This method is typehinted to be an array in \\Joomla\\Utilities\\ArrayHelper::pivot.', JLog::WARNING, 'deprecated');
}
return $result;
}
示例2: testPivot
/**
* Tests the ArrayHelper::pivot method.
*
* @param array $source The source array.
* @param string $key Where the elements of the source array are objects or arrays, the key to pivot on.
* @param array $expected The expected result.
*
* @return void
*
* @dataProvider seedTestPivot
* @covers Joomla\Utilities\ArrayHelper::pivot
* @since 1.0
*/
public function testPivot($source, $key, $expected)
{
$this->assertThat(ArrayHelper::pivot($source, $key), $this->equalTo($expected));
}