- var_dump: documentation ( source)
- array_replace_recursive: documentation ( source)
<?php
$a = [
'counters' => [
'success' => 1,
'failed' => 3
],
'aa' => [1,2,3],
'column_errors' => false
];
$update = array(
);
class Job
{
private $data;
public function __construct(array $data)
{
$this->data = $data;
}
public function getData()
{
return $this->data;
}
public function updateDataWith(array $update)
{
$result = array_replace_recursive($this->data, $update);
if (is_null($result)) {
throw new \RuntimeException;
}
$this->data = $result;
}
}
$job = new Job($a);
$job->updateDataWith($update);
var_dump($job->getData());