I have an array
Array
(
[0] => Array
(
[proomsize] => dasfdsfdsf
[proomtype] => Bedroom
)
[1] => Array
(
[proomsize] => dasfdsfsd
[proomtype] => Bedroom
)
[2] => Array
(
[proomsize] => dfadsf
[proomtype] => KitchenDinner
)
[4] => Array
(
[proomsize] => dafdsads
[proomtype] => Reception
)
[5] => Array
(
[proomsize] => fdsafdsfdsf
[proomtype] => Reception
)
[6] => Array
(
[proomsize] => adfadfdsf
[proomtype] => Reception
)
)
Now i need is if there is more than one $array['proomtype'] of same value i want to append a number at the end in my foreach loop.. so when i loop through it i want a result like this
Bedroom 1 : dasfdsfdsf
Bedroom 2 : dasfdsfsd
KitchenDinner : dfadsf
Reception 1 : dasfdsfsd
Reception 2 : adfdsf
Reception 3 : dfdfdf
how can i achieve that in a single loop i have tried using this
<?php
$BedroomCounter = 0;
if ($value['proomtype'] == 'Bedroom') {
if ($BedroomCounter == 0) {
echo $value['proomtype'] ':' .$value['proomsize'] . '<br>';
}else{
echo $value['proomtype'] . $BedroomCounter . ':' .$value['proomsize'] . '<br>';
}
$BedroomCounter++;
}
the issue is i have repeat this for each n every roomtype.. which is not something i want to.