Access elements of a multidimensional array for comparison.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Access elements of a multidimensional array for comparison.

Post by facets »

Hi All,

Can someone explain to me how to access elements of a multidimensional array?
Here's what my array looks like :

Code: Select all

$date1Range[] = array($date1row['client_id'] => $date1row['total_difference']);
$date2Range[] = array($date2row['client_id'] => $date2row['total_difference']);

Code: Select all

array1 (
  array (
    103 => '116.94',
  )
  array (
    104 => '1467.51',
  )
)

array2 (
  array (
    103 => '116.94',
  )
  array (
    105 => '8400.49',
  )
)
I need to to see if the total_difference for each 'matched' client_id is '<' or '>'.
Here's what I think the pseudo would look like.

if array1.Client_id == array2.Client_id
if array1.Total >= array2.Total
place in new array[]
else
move onto next

Any pointers or suggestion?

tia, Will/.
Post Reply