I have an an array in which I need to assign unique batch id to products belongs to different Retailer
foreach($data as $type){
$grouped_types[$type['retailer']][] = $type;
}
$data is my array
Array
(
[1] => Array
(
[productid] => 1001
[mrp] => 444
[whpoid] => 105
[retailer] => HYD-48AC
[manufacturerbarcode] =>
[comments] =>
[lastmodifiedby] =>
[lastmodifieddate] => 2019-02-12 11:49:19
)
[2] => Array
(
[productid] => 1002
[mrp] => 444
[whpoid] => 106
[retailer] => HYD-48AC
[manufacturerbarcode] =>
[comments] =>
[lastmodifiedby] =>
[lastmodifieddate] => 2019-02-12 11:49:19
)
[3] => Array
(
[productid] => 1003
[mrp] => 444
[whpoid] => 105
[retailer] => HYD-48AC
[manufacturerbarcode] =>
[comments] =>
[lastmodifiedby] =>
[lastmodifieddate] => 2019-02-12 11:49:19
)
[4] => Array
(
[productid] => 1005
[mrp] => 444
[whpoid] => 105
[retailer] => PUN-48AC
[manufacturerbarcode] =>
[comments] =>
[lastmodifiedby] =>
[lastmodifieddate] => 2019-02-12 11:49:19
)
Expected Output So array 2 and 3 belongs to same retailer so they have same batch id.I need to assign unique batch id to each diff retailer but product under same retailer should have same batch id.Kindly help.Thanks in advance
Array
(
[1] => Array
(
[productid] => 1001
[mrp] => 444
[whpoid] => 105
[retailer] => HYD-48AC
[manufacturerbarcode] =>
[comments] =>
[lastmodifiedby] =>
[lastmodifieddate] => 2019-02-12 11:49:19
[batchid] => B001
)
[2] => Array
(
[productid] => 1002
[mrp] => 444
[whpoid] => 106
[retailer] => HYD-48AC
[manufacturerbarcode] =>
[comments] =>
[lastmodifiedby] =>
[lastmodifieddate] => 2019-02-12 11:49:19
[batchid] => B002
)
[3] => Array
(
[productid] => 1003
[mrp] => 444
[whpoid] => 105
[retailer] => HYD-48AC
[manufacturerbarcode] =>
[comments] =>
[lastmodifiedby] =>
[lastmodifieddate] => 2019-02-12 11:49:19
[batchid] => B002
)
[4] => Array
(
[productid] => 1005
[mrp] => 444
[whpoid] => 105
[retailer] => PUN-48AC
[manufacturerbarcode] =>
[comments] =>
[lastmodifiedby] =>
[lastmodifieddate] => 2019-02-12 11:49:19
[batchid] => B003
)