3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $video_url = 'https://www.google.com'; $needles = array('http://', 'https://'); // Normalise the URLs foreach ($needles as $key => $needle) { if (strpos($video_url, $needle) === false) { unset($needles[$key]); } } if (count($needles)) { $video_url = $video_url; } else { $video_url = 'http://' . $video_url; } echo $video_url;
based on hG77b
Output for 4.3.0 - 7.1.0
https://www.google.com