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