I have a string which can be
$string = \"value.\";
OR
$string = \"value1, value2.\";
I want to iterate th
You're absolutely right, you could do it like this:
$string = 'foo, bar, baz.';
$string = preg_replace('/\.$/', '', $string); //Remove dot at end if exists
$array = explode(', ', $string); //split string into array seperated by ', '
foreach($array as $value) //loop over values
{
echo $value . PHP_EOL; //print value
}