I have this multidimensional that I'm getting it from a list. I want the items in that list to be grouped by the "Category", This is the php code:
foreach ($re_services as $re_serv){
$ows_Category = $re_serv->getAttribute("ows_OfferingCatType");
$ows_ServiceID = $re_serv->getAttribute("ows_Title");
$ows_Service = $re_serv->getAttribute("ows_OfferingsName_Edit");
$ows_Hours = $re_serv->getAttribute("ows_Hours");
$Service_Array []= array(
"Category" => $ows_Category,
"ServiceID" => $ows_ServiceID,
"Service" => $ows_Service,
"Hours" => $ows_Hours
); }
And my output is this:
Array
(
[0] => Array
(
[Category] => Styling
[ServiceID] => Blow Dry-Male_104
[Service] => Blow Dry-Male
[Hours] => 1.00000000000000
)
[1] => Array
(
[Category] => Styling
[ServiceID] => Ladies Cut & Blow Dry_101
[Service] => Ladies Cut & Blow Dry
[Hours] => 1.00000000000000
)
[2] => Array
(
[Category] => Styling
[ServiceID] => Longer Blow Dry_103
[Service] => Longer Blow Dry
[Hours] => 2.00000000000000
)
[3] => Array
(
[Category] => Styling
[ServiceID] => Mens Cut & Blow Dry_102
[Service] => Mens Cut & Blow Dry
[Hours] => 1.00000000000000
)
[4] => Array
(
[Category] => Super Services
[ServiceID] => Half Head_106
[Service] => Half Head
[Hours] => 1.00000000000000
)
[5] => Array
(
[Category] => Super Services
[ServiceID] => Highlight/Lowlights_105
[Service] => Highlight/Lowlights
[Hours] => 3.00000000000000
)
[6] => Array
(
[Category] => Super Services
[ServiceID] => Luxury Hair Treatments_109
[Service] => Luxury Hair Treatments
[Hours] => 4.00000000000000
)
[7] => Array
(
[Category] => Technical
[ServiceID] => Bridal Hair_108
[Service] => Bridal Hair
[Hours] => 4.00000000000000
)
[8] => Array
(
[Category] => Technical
[ServiceID] => Hair Up_107
[Service] => Hair Up
[Hours] => 1.00000000000000
)
)
As you can see I have 3 categroies (Styling, Super Services, Technical ). Now the output I need is html tags with values like this:
<select>
<optgroup label="Category">
<option value="ServiceID">Service Hours</option>
</optgroup> </select>
But with out any duplicates with the Category lable. How can I achive that?