@ 2015-09-30T15:27:52Z <?php
function doStuff(string $key, string $value)
{
echo "{$key} => {$value}\n";
}
$array = [
'1' => '1',
'2' => '2',
'3' => '3',
];
foreach ($array as $key => $value) {
var_dump($key);
doStuff($key, $value);
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.31 , 7.1.0 - 7.1.23 , 7.2.0 - 7.2.33 , 7.3.16 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 int(1)
1 => 1
int(2)
2 => 2
int(3)
3 => 3
Output for 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.38 int(1)
Catchable fatal error: Argument 1 passed to doStuff() must be an instance of string, integer given, called in /in/7MtFv on line 16 and defined in /in/7MtFv on line 3
Process exited with code 255 . preferences:dark mode live preview
227.35 ms | 402 KiB | 332 Q