3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $mobileNumber = '0631063771'; $countryCode = '49'; $mobileNumber = str_replace(' ', '', $mobileNumber); if (strpos($mobileNumber, '+') === false) { if (strpos($mobileNumber, '00') === 0) { $mobileNumber = substr($mobileNumber, 2); } elseif (strpos($mobileNumber, '0') === 0 || strpos($mobileNumber, '6') === 0 || strpos($mobileNumber, '7') === 0) { if (strpos($mobileNumber, '0') === 0) { $mobileNumber = substr($mobileNumber, 1); } $mobileNumber = $countryCode . $mobileNumber; } } else { $mobileNumber = substr($mobileNumber, 1); } if (strpos($mobileNumber, '0') === 2) { $arrayNumber = explode('0', $mobileNumber, 2); $mobileNumber = implode($arrayNumber); } echo $mobileNumber;
based on 5VXsr
Output for 5.3.20 - 7.2.0
49631063771