本文整理匯總了PHP中Joomla\Utilities\ArrayHelper::invert方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayHelper::invert方法的具體用法?PHP ArrayHelper::invert怎麽用?PHP ArrayHelper::invert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Joomla\Utilities\ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper::invert方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: invert
/**
* Takes an associative array of arrays and inverts the array keys to values using the array values as keys.
*
* Example:
* $input = array(
* 'New' => array('1000', '1500', '1750'),
* 'Used' => array('3000', '4000', '5000', '6000')
* );
* $output = JArrayHelper::invert($input);
*
* Output would be equal to:
* $output = array(
* '1000' => 'New',
* '1500' => 'New',
* '1750' => 'New',
* '3000' => 'Used',
* '4000' => 'Used',
* '5000' => 'Used',
* '6000' => 'Used'
* );
*
* @param array $array The source array.
*
* @return array The inverted array.
*
* @since 12.3
* @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::invert instead
*/
public static function invert($array)
{
return ArrayHelper::invert($array);
}
示例2: testInvert
/**
* Tests the ArrayHelper::invert method.
*
* @param array $input The array being input.
* @param string $expected The expected return value.
*
* @return void
*
* @dataProvider seedTestInvert
* @since 1.0
*/
public function testInvert($input, $expected)
{
$this->assertThat(ArrayHelper::invert($input), $this->equalTo($expected));
}