public function testSetLength() { $array = CArray::fromElements("a", "b"); CArray::setLength($array, 3); $this->assertTrue($array->getSize() == 3 && $array[0] === "a" && $array[1] === "b"); CArray::setLength($array, 1); $this->assertTrue($array->getSize() == 1 && $array[0] === "a"); }
/** * Resizes an array to a new length. * * No elements are lost if the array grows in size and all elements that are allowed by the new length are kept if * the array shrinks. * * @param int $newLength The new length. * * @return void */ public function setLength($newLength) { CArray::setLength($this->m_splArray, $newLength); }