RE: [PHP] Re: Comparing arrays confusion [Solution]

From: Date: Tue, 27 Apr 2004 13:55:09 +0000
Subject: RE: [PHP] Re: Comparing arrays confusion [Solution]
Groups: php.general 
Request: Send a blank email to php-general+get-184757@lists.php.net to get a copy of this message
> I am having trouble properly comparing a couple of arrays. (Actually >three arrays) Thanks to Torsten for helping my see the light at the end of the array. Much simpler than what I was trying. [Solution] $intsecarray = array_intersect($classarray, $compcls); $intsecdiff = array_diff($compcls, $intsecarray); foreach($intsecarray as $key=>$value){ $intseccombined[$value] = $percentage[$key]; } foreach($compcls as $key=>$value){ $compcls2[$value] = 0; } $lastarray = array_merge($compcls2, $intseccombined); foreach($lastarray as $key=>$value){ if(!empty($value)){ if($bgcolor == '#FFFFFF'){ $bgcolor = '#F2F2F2'; } else{ $bgcolor = '#FFFFFF'; } } else{ $bgcolor = '#FFE6E7'; } echo "<tr bgcolor=$bgcolor><td>$key</td><td>$value</td></tr>"; } alex hogan ****************************************************************** The contents of this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. The views stated herein do not necessarily represent the view of the company. If you are not the intended recipient of this e-mail you may not copy, forward, disclose, or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please e-mail the sender. ******************************************************************

« previous php.general (#184757) next »