Im trying to create a invoice data but i face problem where the driver name should be replaced with driver number .
for example current array
Array
(
[0] => Array
(
[quantity] => 20
[unit_price] => 20
[driver] => Ivan
[driver_id] => 4
)
[1] => Array
(
[quantity] => 10
[unit_price] => 50
[driver] => Ivan
[driver_id] => 4
)
[2] => Array
(
[quantity] => 20
[unit_price] => 10
[driver] => John
[driver_id] => 5
)
[3] => Array
(
[quantity] => 20
[unit_price] => 20
[driver] => John
[driver_id] => 5
)
)
i want to change [driver] => Ivan to [driver] => Driver 1 and [driver] => John to [driver] => Driver 2 and so on for the next driver , the problem is data is dynamic and i dont know how to do it , at the end im looking to get result like this
Array
(
[0] => Array
(
[quantity] => 20
[unit_price] => 20
[driver] => Driver 1
[driver_id] => 4
)
[1] => Array
(
[quantity] => 10
[unit_price] => 50
[driver] => Driver 1
[driver_id] => 4
)
[2] => Array
(
[quantity] => 20
[unit_price] => 10
[driver] => Driver 2
[driver_id] => 5
)
[3] => Array
(
[quantity] => 20
[unit_price] => 20
[driver] => Driver 2
[driver_id] => 5
)
)
What i tried to do isnt work correct
$i = 1;
foreach ($fetchCustomerProfitIn as $report) {
echo "Driver - $i";
echo "$report['quantity']";
echo "$report['unit_price']";
i ++
}
result become incorrect like this
Array
(
[0] => Array
(
[quantity] => 20
[unit_price] => 20
[driver] => Driver 1
[driver_id] => 4
)
[1] => Array
(
[quantity] => 10
[unit_price] => 50
[driver] => Driver 2
[driver_id] => 4
)
[2] => Array
(
[quantity] => 20
[unit_price] => 10
[driver] => Driver 3
[driver_id] => 5
)
[3] => Array
(
[quantity] => 20
[unit_price] => 20
[driver] => Driver 4
[driver_id] => 5
)
)