3v4l.org

run code in 300+ PHP versions simultaneously
<?php $reg_exUrl = "/((http|https)\:\/\/|(www)\.)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; $text = 'demo www.google.bg'; preg_match_all($reg_exUrl, $text, $matches); $usedPatterns = array(); foreach($matches[0] as $pattern){ if(!array_key_exists($pattern, $usedPatterns)){ $usedPatterns[$pattern]=true; if(preg_match('%https://',$pattern)) { $start = "https://"; elseif(preg_match('%http://',$pattern){ $start = "http://"; }else { $start = "http://"; } $text = str_replace ($pattern, "<a href='{$start}{$pattern}' target='_blank'>{$pattern}</a> ", $text); } } echo $text;
Output for 5.4.0 - 5.4.28
Parse error: syntax error, unexpected 'elseif' (T_ELSEIF) in /in/lTTSY on line 12
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_ELSEIF in /in/lTTSY on line 12
Process exited with code 255.

preferences:
185.19 ms | 1395 KiB | 65 Q