/** * 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); }
/** * 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)); }