3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function callbackFunction( $matches) { print_r($matches); return 'lol'; } $pattern = '@\\<img src\\="http\\://((i\\.imgur\\.com))/.+?"@u'; $subject = '[13-Jul-2014 14:07:07 UTC] sdfsdfsdfesdwsasdvesfdrsad<br>&nbsp;<br>&nbsp;<br><img src="http://i.imgur.com/xhQHD6w.gif" alt="xhQHD6w.gif">sdsdfsasfdasfasdas<br>&nbsp;<br><img src="http://i.imgur.com/xhQHD6w.gif" alt="xhQHD6w.gif"><br><img src="http://i.img1ur.com/xhQHD6w.gif" alt="xhQHD6w.gif">'; print_r( preg_replace_callback($pattern, 'callbackFunction', $subject, -1 ) );
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => <img src="http://i.imgur.com/xhQHD6w.gif" [1] => i.imgur.com [2] => i.imgur.com ) Array ( [0] => <img src="http://i.imgur.com/xhQHD6w.gif" [1] => i.imgur.com [2] => i.imgur.com ) [13-Jul-2014 14:07:07 UTC] sdfsdfsdfesdwsasdvesfdrsad<br>&nbsp;<br>&nbsp;<br>lol alt="xhQHD6w.gif">sdsdfsasfdasfasdas<br>&nbsp;<br>lol alt="xhQHD6w.gif"><br><img src="http://i.img1ur.com/xhQHD6w.gif" alt="xhQHD6w.gif">