3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array('some-key' => 'Needle Value'); $string = 'I am the Needle Value'; foreach ($data as $key => $val) { if(strstr($string, $val)) { $string = str_replace($val, '<a href="'.$key.'">'.$val.'</a>', $string); } } echo $string;

preferences:
30.41 ms | 402 KiB | 5 Q