Question: I have a array which holds one or more values. If it holds more than one value I am using explode to extract the values.

I have to write a loop, since I do not know the number of values in the array.

Here is my loop:

$m\_totalProFood is an array with multiple values.

```
$m_totalProFood = Chicken breast, Tofu,

$i=1;
foreach ($m_totalProFood as $m_proFoodName1)
{
    $m_proFoodValues1 = explode(", ", $m_totalProFood);
    echo "test ".$m_proFoodValues1;
    $i++;
}

```

If I extract individual values then it come correctly

```
$m_proFoodValues1 = explode(", ", $m_totalProFood);
echo $m_proFoodValues1[1];

```

I know I am doing something wrong. Any help will be appreciated.

Answer: 
answer 

```
 $i=1;
$array = explode(', ', $m_totalProFood);
foreach ($array as $m_proFoodName)
{
echo "test ".rtrim($m_proFoodName,',');
$i++;
}

```
ahhh i see.....

```
$i=1;
$array = explode(', ', $m_totalProFood);
foreach ($array as $m_proFoodName)
{
    echo "test ".$m_proFoodName;
    $i++;
}

```

first make an array out of your string-list, then iterate over it by using foreach