This is my first post. I've been doing php for only a few months now.
I work for a company that repairs cameras and lenses. We get in lenses under an invoice and each invoice has multiple service orders. We can get more than one invoice at a time. Each service order can have 1 or more lenses in it. Here is a visual example:
[text]
INVOICE: XXXXXXX
SERVICE ORDER MODEL SERIAL REPAIR TYPE COMMENT
329327 XXXXXX 932932 STANDARD DO IT REALLY FAST THE CUSTOMER IS A DICK
902308 XXXXXX 932093 MAJOR NONE
[/text]
So I've made a confusing array:
[text]
INVOICE => SERVICEORDER => 'model' => xxxxx
'serial' => xxxxx
'rep_type' => xxxxx
[/text]
The INVOICE is the $key and SERVICEORDER is the $value AND a $key and 'model', 'serial', 'repairtype' are all $keys and they each have their $values.
etc... I hope this is all making sense so far...
I've made a couple foreach loops.
Code: Select all
foreach ($invoice as $inv => $serviceOrder){
foreach ($serviceOrder as $so_num => $data){
foreach ($data as $key => $value){
// Want I want here is some way to make each $key a variable name with its appropriate value, ie:
// $model = $value;
// $serial = $value;
// $repair_type = $value;
}
}
}
Am I going about this wrong? I've tried using an object... but I got so confused... also I can't figure out how to foreach an object so I can separate each invoice and it's service orders...
Any help would be greatly appreciated.
Thank you for your time!