3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $phonecodes['pl'] = 48; $country= 'pl'; $tel = '+4812321312312312'; function checkCountryCode($tel, $part) { global $phonecodes, $country; for ($i = 1; $i <= 3; $i++) { $codeToCheck = substr($tel, 1, $i); foreach ($phonecodes as $key => $val) { if ($codeToCheck == $val) { $code = c; echo $code; switch($part){ case 'phonecode': echo $key; break; case 'a': echo $val; break; case 'd': echo 'dupa'; break; } } } } if ($code == '') echo $country; } checkCountryCode($tel, 'phonecode');
based on kvaIa
Output for 7.2.0
Warning: Use of undefined constant c - assumed 'c' (this will throw an Error in a future version of PHP) in /in/aZIcp on line 13 cpl
Output for 5.3.17 - 7.1.10
Notice: Use of undefined constant c - assumed 'c' in /in/aZIcp on line 13 cpl