3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $body = '<blockquote class="twitter-tweet" data-lang="ja"><p lang="en" dir="ltr">Thank you ! ~ that is all :) <a href="https://t.co/4evflUT84g">pic.twitter.com/4evflUT84g</a></p>— Chicago Police (@Chicago_Police) <a href="https://twitter.com/Chicago_Police/status/877727536125419520">2017年6月22日</a></blockquote><script async="" src="//platform.twitter.com/widgets.js" charset="utf-8"></script>'; $body = preg_replace_callback('!(https://twitter.com/[^/]+?/status/\d+)!s', function ($matches) { return '[[embed-twitter]](' . trim($matches[1]) . ')'; }, $body); $body = preg_replace_callback('!(<blockquote class="twitter-tweet" data-lang="ja">.*?</blockquote>)!s', function ($matches) { return '[[embed-twitter]](' . trim($matches[2]) . ')'; }, $body); echo $body; ?>
based on GT1ra
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0rc3
Notice: Undefined offset: 2 in /in/FM1Pf on line 9 [[embed-twitter]]()<script async="" src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
Output for hhvm-3.15.4
Notice: Undefined index: 2 in /in/FM1Pf on line 9 Warning: trim() expects parameter 1 to be string, null given in /in/FM1Pf on line 9 [[embed-twitter]]()<script async="" src="//platform.twitter.com/widgets.js" charset="utf-8"></script>