compare value in 2 multidimension array
| From: | weetat | Date: | Sat, 29 Jul 2006 07:08:15 +0000 |
| Subject: | compare value in 2 multidimension array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-239868@lists.php.net to get a copy of this message | ||
Hi all ,
I have 2 multidimension array as shown below:
I need to compare all values in the 2 multidimension array where there are any elements values updated or a new elements or be deleted.
Updated mean when value in $temptablearr element is different from value in $currenttablearr element, update status to 'Updated'
New mean when value in $temptablearr element is not exists in $currenttablearr , update status to 'New'
Deleted mean when value in $currenttablearr element is not exists in $temptablearr elements, update status to 'Deleted'
If the value are the same in 2 array elements , update status to 'SKIP'
The result of comparing is array of data which "deleted","updated" and "new" except "SKIP" status.
I have been trying many way to do compare in array unsuccessful.
Anybody have any ideas or suggestions how to solve the issue , your help is much appreciated. Thanks
$temptablearr = array(0 =>
array("chassis_serial_no"=>"1235",
"country"=>"Malaysia",
"card_serial_no"=>"cd-12345",
"card_model"=>"ws8950"),
1 =>
array("chassis_serial_no"=>"1235",
"country"=>"Malaysia",
"card_serial_no"=>"cd-890",
"card_model"=>"ws1234"),
2 =>
array("chassis_serial_no"=>"8888",
"country"=>"Indonesia",
"card_serial_no"=>"cd-12345",
"card_model"=>"ws999"),
);
$currenttablearr = array( 0 =>
array("chassis_serial_no"=>"1235",
"country"=>"Malaysia",
"card_serial_no"=>"cd-12345",
"card_model"=>"ws8950"),
1=>
array("chassis_serial_no"=>"1235",
"country"=>"Singapore",
"card_serial_no"=>"cd-890",
"card_model"=>"ws1234"),
);