Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is a fix:</p> <pre><code>&lt;?php function _check4Links($text){ $pattern = '#\b(([\w-]+://?|www[.])[^\s()&lt;&gt;]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#'; return preg_replace_callback($pattern, 'fnc', $text); } function fnc($matches) { $url = array_shift($matches); $url_parts = parse_url($url); if(preg_match("%(?:youtube\.com/(?:user/.+/|(?:v|e(?:mbed)?)/|.*[?&amp;]v=)|youtu\.be/)([^\"&amp;?/ ]{11})%i", $url, $match)){ return '&lt;iframe title="YouTube video player" class="youtube-player" type="text/html" width="400" height="244" src="http://www.youtube.com/embed/'.$match[1].'" frameborder="0" allowFullScreen&gt;&lt;/iframe&gt;'; } else { $text = parse_url($url, PHP_URL_HOST) . parse_url($url, PHP_URL_PATH); $text = preg_replace("/^www./", "", $text); $last = -(strlen(strrchr($text, "/"))) + 1; if ($last &lt; 0) { $text = substr($text, 0, $last) . "&amp;hellip;"; } return sprintf('&lt;a target="_blank"rel="nofollow" href="%s"&gt;%s&lt;/a&gt;', $url, $text); } } $txt = &lt;&lt;&lt;TXT Let's do some tests! http://www.google.com http://www.youtube.com/watch?v=L25R4DR79mU TXT; echo _check4Links($txt); ?&gt; </code></pre> <p>The output is:</p> <pre><code>Let's do some tests! &lt;a target="_blank"rel="nofollow" href="http://www.google.com"&gt;google.com&lt;/a&gt; &lt;iframe title="YouTube video player" class="youtube-player" type="text/html" width="400" height="244" src="http://www.youtube.com/embed/L25R4DR79mU" frameborder="0" allowFullScreen&gt;&lt;/iframe&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload