public function testOrganizeBy() { $expected = array('ai' => array('i' => 'ai', 'j' => 'dj', 'k' => 'dk'), 'bi' => array('i' => 'bi', 'j' => 'bj', 'k' => 'bk')); $this->assertEquals($expected, Arr::organizeBy($this->input, 'i')); $expected = array('ai' => array('i' => 'ai', 'j' => 'aj'), 'bi' => array('i' => 'bi', 'j' => 'bj', 'k' => 'bk')); $this->assertEquals($expected, Arr::organizeBy($this->input, 'i', true)); }
/** * Reorganize a 2D array, using the values within internal arrays * as keys for the external array. * @param mixed $key * @param bool $skip_duplicates * @return Arr */ public function organizeBy($key, $skip_duplicates = false) { return new self(Arr::organizeBy($this->data, $key, $skip_duplicates)); }