Exemplo n.º 1
0
 public function testInsertArray()
 {
     $array = CArray::fromElements("a", "b", "c", "d", "e");
     CArray::insertArray($array, 3, CArray::fromElements("x", "y"));
     $this->assertTrue(CArray::equals($array, CArray::fromElements("a", "b", "c", "x", "y", "d", "e")));
     $array = CArray::fromElements("a", "b", "c", "d", "e");
     CArray::insertArray($array, 0, CArray::fromElements("x", "y"));
     $this->assertTrue(CArray::equals($array, CArray::fromElements("x", "y", "a", "b", "c", "d", "e")));
     // Special cases.
     $array = CArray::fromElements("a", "b", "c", "d", "e");
     CArray::insertArray($array, 5, CArray::fromElements("x", "y"));
     $this->assertTrue(CArray::equals($array, CArray::fromElements("a", "b", "c", "d", "e", "x", "y")));
     $array = CArray::make();
     CArray::insertArray($array, 0, CArray::fromElements("x", "y"));
     $this->assertTrue(CArray::equals($array, CArray::fromElements("x", "y")));
 }
Exemplo n.º 2
0
 /**
  * Inserts the elements of an array into another array.
  *
  * As a special case, the position of insertion can be equal to the array's length, which would make this method
  * work like `pushArray` method.
  *
  * @param  int $atPos The position at which the new elements are to be inserted.
  * @param  array $insertArray The array containing the elements to be inserted.
  *
  * @return void
  */
 public function insertArray($atPos, $insertArray)
 {
     CArray::insertArray($this->m_splArray, $atPos, $insertArray);
 }