I'm trying to display hyperlinks to screen but only if a corresponding ID is recorded in a string.
<?php
function check($i, $s) {
if (preg_match('/'.$i.'/',$test)) echo $s;
}
$test = "000,001,002,003,004,005";
check("001","<a href=''>This is in the test string - 001</a>");
check("003","<a href=''>This is in the test string - 003</a>");
check("006","<a href=''>This is in the test string - 006</a>");
check("020","<a href=''>This is in the test string - 020</a>");
?>
The desired output would be:
<a href=''>This is in the test string - 001</a>
<a href=''>This is in the test string - 003</a>
As they are the only two matches to the values in the string.
This isn't working.. Can you advise why and how to get it working.?
Thanks