3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "<a href='mailto:francesco.argonautivacanze@gmail.com'>francesco.argonautivacanze@gmail.com</a><a href='https://wa.me/39+393479488495'>invia offerta</a>"; $pattern = "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i"; preg_match($pattern, $str, $matches); print_r($matches); echo $matches[0]; $url = "aaaaaaa"; function replace_waUrl($waurl,$new_url,$html_body){ $pattern = "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i"; preg_match($pattern, $waurl, $matches); $old_url = $matches[0]; $newbody = str_replace($old_url,$new_url,$html_body); return $newbody; } echo replace_waUrl($url,"ffffff",$str);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Array ( [0] => https://wa.me/39+393479488495 ) https://wa.me/39+393479488495 Warning: Undefined array key 0 in /in/mWDQA on line 11 Deprecated: str_replace(): Passing null to parameter #1 ($search) of type array|string is deprecated in /in/mWDQA on line 12 <a href='mailto:francesco.argonautivacanze@gmail.com'>francesco.argonautivacanze@gmail.com</a><a href='https://wa.me/39+393479488495'>invia offerta</a>
Output for 8.0.1 - 8.0.30
Array ( [0] => https://wa.me/39+393479488495 ) https://wa.me/39+393479488495 Warning: Undefined array key 0 in /in/mWDQA on line 11 <a href='mailto:francesco.argonautivacanze@gmail.com'>francesco.argonautivacanze@gmail.com</a><a href='https://wa.me/39+393479488495'>invia offerta</a>

preferences:
95.06 ms | 402 KiB | 91 Q