3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mapping = [ "AccountId" => "account_id", "Id" => "master_id", "Name" => "name" ]; $input = [ "AccountId" => "18", "Id" => "53600065", "Name" => "Awesome Test Company From SS", "Financial" => [ "vat" => "12345", ] ]; $output = []; foreach ($mapping as $from => $to) { if (array_key_exists($from, $input)) { $output[$to] = $input[$from]; } } var_dump($output);

preferences:
39.45 ms | 402 KiB | 5 Q