Help Accessing my mulitdimensional array

This code is kind of choppy, let me know if you need more detail.

I have a multidimensional array that I'm having trouble getting the data from.

There is a global array that gets assigned data either by editing or appending.  This code was existing and functioning:

$oID = 12345;
foreach($GLOBALS['order']->totals as $key => $total) {
	if($total['class'] == $order_total['code']) {
	// Update the information in the order
		$GLOBALS['order']->totals[$key]['title'] = $order_total['title'];
		$GLOBALS['order']->totals[$key]['value'] = $order_total['value'];
		$GLOBALS['order']->totals[$key]['text'] = $order_total['text'];

		$found = true;

if(!$found) {
	$GLOBALS['order']->totals[] = array(
	'class' => $order_total['code'],
	'title' => $order_total['title'],
	'value' => $order_total['value'],
	'text' => $order_total['text'],
	'sort_order' => $order_total['sort_order']

Open in new window

I passed the array to a function.  (I realize that is not required for a global, but I'm doing it in case I'm able to turn the $GLOBALS['order'] into a local variable);

update_order_total($oID, $GLOBALS['order'])

Open in new window

Here's the function declaration:
function update_order_total($oID, $order_total)

Open in new window

And here's my sad failed attempt inside the function to get the values from that array:

foreach ($order_total as $current_total) {
	//START test	
		$sql_data_array = array(
				'orders_id' => (int)$oID,					
			'title' => $current_total['class'],
				'text' => $current_total['text'],
				'value' => (is_numeric($current_total['value'])) ? $current_total['value'] : '0',
				'class' => 'ot_custom_' . $i,
				'sort_order' => $current_total['sort_order']
//then in insert this into a row in the database.  
//The class field and order_id field have values, and are okay. 
//The $current_total fields are blank.

Open in new window

Can you see what I'm doing wrong?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Any chance you can reduce this to the SSCCE?  You only need to show us the data you have and the data you want to get from the data you have.  That will be much more effective than looking at code that we all know does not work!
christamccAuthor Commented:
It's only the last chuck of code that doesn't work, I need to specifically use the first chuck of code above, which I mentioned is working.  

The first chuck of code fills a multidimensional array. (needs to stay as is)
ie: $GLOBALS['order']->totals[] = array('class' => $order_total['code'])

Solution: I need to pass that $GLOBALS['orders'] array to a variable and then loop through that new array variable to get the values.
christamccAuthor Commented:
I figured it out.  My function call should be:

update_order_total($oID, $GLOBALS['order']->total)

rather than

update_order_total($oID, $GLOBALS['order'])

Everything else was fine.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
christamccAuthor Commented:
There were no other solutions posted and this fixes my problem.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.