3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $pattern = '%(?<attr>src|href)="(?<host>.*?)(?<media>/media/[^"]+)"%i'; $content = <<<CONTENT <p><img alt="" src="/media/images/logo_medias/TV/TF1.jpg" style="height:22px; width:60px" />&nbsp;&nbsp;<img alt="" src="/media/images/logo_medias/TV/W9.jpg" style="height:22px; width:60px" />&nbsp; <img alt="" src="/media/images/logo_medias/TV/Gulli.jpg" style="height:29px; width:30px" /><strong>&nbsp;</strong><img alt="" src="/media/images/logo_medias/TV/DISNEY%20CHANNEL.jpg" style="color:rgb(76, 76, 76); font-size:15.555556297302246px; height:40px; line-height:22.986112594604492px; width:44px" /><strong>&nbsp;<img alt="" src="/media/images/logo_medias/TV/NT1.jpg" style="height:29px; width:35px" /></strong>&nbsp;-&nbsp;Campagne de spots<br /> <img alt="" src="http://infoscom.umf.dev/media/images/Pluzz.jpg" style="height:219px; width:219px" /><a alt="" href="http://infoscom.umf.dev/media/images/Pluzz.jpg" style="height:219px; width:219px" /></p> CONTENT; $callback = function($match) { var_dump($match); return $match[0]; }; var_dump(preg_replace_callback($pattern, $callback, $content));
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(7) { [0]=> string(42) "src="/media/images/logo_medias/TV/TF1.jpg"" ["attr"]=> string(3) "src" [1]=> string(3) "src" ["host"]=> string(0) "" [2]=> string(0) "" ["media"]=> string(36) "/media/images/logo_medias/TV/TF1.jpg" [3]=> string(36) "/media/images/logo_medias/TV/TF1.jpg" } array(7) { [0]=> string(41) "src="/media/images/logo_medias/TV/W9.jpg"" ["attr"]=> string(3) "src" [1]=> string(3) "src" ["host"]=> string(0) "" [2]=> string(0) "" ["media"]=> string(35) "/media/images/logo_medias/TV/W9.jpg" [3]=> string(35) "/media/images/logo_medias/TV/W9.jpg" } array(7) { [0]=> string(44) "src="/media/images/logo_medias/TV/Gulli.jpg"" ["attr"]=> string(3) "src" [1]=> string(3) "src" ["host"]=> string(0) "" [2]=> string(0) "" ["media"]=> string(38) "/media/images/logo_medias/TV/Gulli.jpg" [3]=> string(38) "/media/images/logo_medias/TV/Gulli.jpg" } array(7) { [0]=> string(55) "src="/media/images/logo_medias/TV/DISNEY%20CHANNEL.jpg"" ["attr"]=> string(3) "src" [1]=> string(3) "src" ["host"]=> string(0) "" [2]=> string(0) "" ["media"]=> string(49) "/media/images/logo_medias/TV/DISNEY%20CHANNEL.jpg" [3]=> string(49) "/media/images/logo_medias/TV/DISNEY%20CHANNEL.jpg" } array(7) { [0]=> string(42) "src="/media/images/logo_medias/TV/NT1.jpg"" ["attr"]=> string(3) "src" [1]=> string(3) "src" ["host"]=> string(0) "" [2]=> string(0) "" ["media"]=> string(36) "/media/images/logo_medias/TV/NT1.jpg" [3]=> string(36) "/media/images/logo_medias/TV/NT1.jpg" } array(7) { [0]=> string(52) "src="http://infoscom.umf.dev/media/images/Pluzz.jpg"" ["attr"]=> string(3) "src" [1]=> string(3) "src" ["host"]=> string(23) "http://infoscom.umf.dev" [2]=> string(23) "http://infoscom.umf.dev" ["media"]=> string(23) "/media/images/Pluzz.jpg" [3]=> string(23) "/media/images/Pluzz.jpg" } array(7) { [0]=> string(53) "href="http://infoscom.umf.dev/media/images/Pluzz.jpg"" ["attr"]=> string(4) "href" [1]=> string(4) "href" ["host"]=> string(23) "http://infoscom.umf.dev" [2]=> string(23) "http://infoscom.umf.dev" ["media"]=> string(23) "/media/images/Pluzz.jpg" [3]=> string(23) "/media/images/Pluzz.jpg" } string(860) " <p><img alt="" src="/media/images/logo_medias/TV/TF1.jpg" style="height:22px; width:60px" />&nbsp;&nbsp;<img alt="" src="/media/images/logo_medias/TV/W9.jpg" style="height:22px; width:60px" />&nbsp; <img alt="" src="/media/images/logo_medias/TV/Gulli.jpg" style="height:29px; width:30px" /><strong>&nbsp;</strong><img alt="" src="/media/images/logo_medias/TV/DISNEY%20CHANNEL.jpg" style="color:rgb(76, 76, 76); font-size:15.555556297302246px; height:40px; line-height:22.986112594604492px; width:44px" /><strong>&nbsp;<img alt="" src="/media/images/logo_medias/TV/NT1.jpg" style="height:29px; width:35px" /></strong>&nbsp;-&nbsp;Campagne de spots<br /> <img alt="" src="http://infoscom.umf.dev/media/images/Pluzz.jpg" style="height:219px; width:219px" /><a alt="" href="http://infoscom.umf.dev/media/images/Pluzz.jpg" style="height:219px; width:219px" /></p> "
Output for 4.4.3 - 4.4.9, 5.1.0 - 5.1.1, 5.1.3 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/tnD8u on line 13
Process exited with code 255.
Output for 4.4.2, 5.1.2
Parse error: syntax error, unexpected T_FUNCTION in /in/tnD8u on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/tnD8u on line 13
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/tnD8u on line 13
Process exited with code 255.