- var_dump: documentation ( source)
<?php
class Test {
public $test = [];
public function __construct() {
$this->test['foo'] = 'foo';
$this->test['bar'] = 'bar';
}
public function getTest(): array {
return $this->test;
}
}
$test = new Test;
foreach($test->getTest() as $key => $value) {
if ($key === 'foo') {
$test->test['baz'] = 'baz';
}
var_dump($value);
}