I have tried everything I know and I have failed totally to parse this multi dimensional array so that I can get the keys and values out of both the inner and outer array for saving to a DB.
array:10 [▼
"_token" => "aHgDik0zuDxxBqYgbi0ZTkaPyG3CVwk5WO7LtU6u"
"contractor_invoice_no" => ""
"date" => "26-11-2015"
"contractor_reference" => "sdfsdf"
"workorder_reference" => "151 alandale"
"square_installed" => "455"
"square_invoice" => "677"
"other_work_" => array:3 [▶]
"other_invoice_" => array:3 [▶]
"comments" => "comments"
]
I have tried nested foreach loops and I always get an array to string conversion error when echoing out the values of the outer array. I will not show you every single attempt I have made, but this attempt below gives me all the outer array but then shows an error on the echo statement, which tells me it is failing when it hits the inner array.
foreach($invoice as $key=> $value)
{
echo " Data $value Key $key"; // Array to String conversion error here !
if (is_array($value) || is_object($value))
{
foreach ($value as $sample=>$data)
{
echo "Key $sample Data $data";
}
}
}
How do I make this work ?
MANY THANKS !