3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php echo formatsMobileNumber('+33631063771', 33).\n; echo formatsMobileNumber('+330631063771', 33); echo formatsMobileNumber('+49631063771', 49); echo formatsMobileNumber('0049631063771', 49); echo formatsMobileNumber('00390631063771', 39); echo formatsMobileNumber('0631063771', 33); echo formatsMobileNumber('631063771', 39); function formatsMobileNumber($mobileNumber, $countryCode) { $mobileNumber = str_replace(' ', '', $mobileNumber); if (strpos($mobileNumber, '+') === false) { if (strpos($mobileNumber, '00') === 0) { $mobileNumber = substr($mobileNumber, 2); } else { if (strpos($mobileNumber, '0') === 0) { $mobileNumber = substr($mobileNumber, 1); } $mobileNumber = $countryCode . $mobileNumber; } } else { $mobileNumber = substr($mobileNumber, 1); } $splitCountryCode = explode($countryCode, $mobileNumber); if (strpos($splitCountryCode[1], '0') === 0) { $arrayNumber = explode('0', $mobileNumber, 2); $mobileNumber = implode($arrayNumber); } return $mobileNumber; }
based on prH2E
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Undefined constant 'n' in /in/Xnmlc:3 Stack trace: #0 {main} thrown in /in/Xnmlc on line 3
Process exited with code 255.
Output for 5.3.21 - 5.6.28
Fatal error: Undefined constant 'n' in /in/Xnmlc on line 3
Process exited with code 255.