3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Se { public $data1; public function setData(array $data) { if (empty($data)) { throw new InvalidArgumentException('The name of an employee cannot be empty.'); } $this->data1 = array_values($data); //you error was here, no need to to assign $data twice so I deleted top line. } public function getE() { return $this->data1[0]; } } $tmpaaa = array('3333','222'); $ttt = new Se(); $ttt->setData($tmpaaa); echo $ttt->getE();

preferences:
52.86 ms | 402 KiB | 5 Q