3v4l.org

run code in 300+ PHP versions simultaneously
<?php function formatAds(array $ad): array { $ad['last_name'] = ucfirst($ad['last_name']); $ad['first_name'] = ucfirst($ad['first_name']); $phoneNumber = preg_replace(['/ /', '/^0?33/'], ['', '0'], $ad['phone_number']); $ad['phone_number'] = preg_match('/^0[1-9][\d]{8}$/', $phoneNumber, $matches) ? $matches[0] : null; return $ad; } $ad1 = [ "last_name" => "foo", "first_name" => "bar", "phone_number" => "04 55 66 77 11", ]; $ad2 = [ "last_name" => "flow", "first_name" => "blow", "phone_number" => "334 55 66 77 11", ]; $ad3 = [ "last_name" => "beez", "first_name" => "wiiz", "phone_number" => "0334 55 66 77 11", ]; print_r(formatAds($ad1)); print_r(formatAds($ad2)); print_r(formatAds($ad3));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [last_name] => Foo [first_name] => Bar [phone_number] => 0455667711 ) Array ( [last_name] => Flow [first_name] => Blow [phone_number] => 0455667711 ) Array ( [last_name] => Beez [first_name] => Wiiz [phone_number] => 0455667711 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
111.27 ms | 406 KiB | 5 Q