3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [ 'counters' => [ 'success' => 1, 'failed' => 3 ], 'aa' => [1,2,3], 'column_errors' => false ]; $update = array( 'column_errors' => true, ); 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());
based on vsTVj
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0alpha1
array(3) { ["counters"]=> array(2) { ["success"]=> int(1) ["failed"]=> int(3) } ["aa"]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } ["column_errors"]=> bool(true) }