Jump to content

accessing a value in a multidimensional associative array


dmikester1

Recommended Posts

I'm having some troubles with this one.  I set up my array like so:

$POs[] = array(
  $jobID=>array(
  'FSME' => $matTotal,
  'FSMC' => $matTotal,
  'FSDE' => $draftingTotal,
  ...

And say $jobID is equal to 312.

 

Now I am trying to access one of those values.  I tried:

$POs[$jobID]['FSME']

with $jobID being 312.  Then I get "Notice: Undefined offset: 312 in..."  Any ideas how I can access this variable?

Thanks

Mike

You need to change it to:

$POs[$jobID] = array('FSME' => $matTotal, ...);

 

Or access it using:

$POs[0][312]['FSMC'];

Thank you.  I changed the way I was inserting in the array.  I knew there had to be an easier way than what I was doing, but was having a brain fart or something.

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.