- var_dump: documentation ( source)
- array_splice: documentation ( source)
<?php
class Based {
private array $arr = ["zero", "one", "two", "three", "four", "five"];
public function removeElementFromArr (int $index): void {
$tmp = $this->getArr();
array_splice($tmp, $index, 1);
$this->setArr($tmp);
}
public function getArr (): array {
return $this->arr;
}
public function setArr (array $newArr) {
$this->arr = $newArr;
}
}
$obj = new Based();
var_dump($obj->getArr());
$obj->removeElementFromArr(3);
var_dump($obj->getArr());