- strstr: documentation ( source)
- str_replace: documentation ( source)
<?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;