3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ReformatPhoneNumber($number) { if(strlen($number) > 12 || strlen($number) < 7) throw new Exception("Invalid phone number"); if(preg_match('/^\d+(\d-\d)?(\d\s\d)?\d+$/', $number) === 1) return str_replace(array('-', ' '), '', $number); } echo ReformatPhoneNumber('1234-567');
Output for git.master, git.master_jit, rfc.property-hooks
1234567

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:
58.44 ms | 401 KiB | 8 Q