Can anyone help me output "Zinfandel|Sauvignon Blanc" from "This very nice wine is produced in California and is made from Zinfandel and Sauvignon Blanc grapes."?
Please also notice the case insensitivity. I prefer the output with capitals on first words.
I created the following code :
<?php
$ds = "Riesling|Sauvignon Blanc|Zinfandel|Muscat/i";
$string = "This very nice wine is produced in California and is made from zinfandel and Sauvignon Blanc grapes.";
echo "This is the string to extract the grapes from : ";
echo $string;
echo "<br>";
echo "These are the grapes that need to be matched in a regular expression : ";
echo $ds;
echo "<br>";
$matches = array();
$search = preg_match_all($ds, $string, $matches);
foreach ($matches[1] as $match) {
echo $match;
// I want this to output "Zinfandel|Sauvignon Blanc" with a pipeline between the matches
}
?>
Any help pretty much appreaciated!