You might want something more like.. foreach ($_POST as $nkey => $new) { $old = $olddata[$nkey]; if ($old == $new) { // Match } else { // No Match } }
Note: This will not check for things that are not inside $_POST. On 02/07/06, Wade Smart <[EMAIL PROTECTED]> wrote: > > > > > > > 07022006 1530 GMT-6 > > I am wanting to compare two things: the information from the $_POST and > my existing data in $olddata -> this is an array obviously. > > I always forget how to use this foreach inside one another. > I want to check $_POST['fname'] against $olddata['fname'] and if they > are the same, for simple testing I want to print out SAME and > if different, DIFFERENT. > > foreach ($_POST as $nkey => $new){ > foreach($olddata as $okey => $old) { > if ($new == $old) { > print '"'.$new.'" AND "'.$old.'" are the <b style="color:red">SAME</b>; > Next... <br />'; > } else { > print '"'.$new.'" AND "'.$old.'" are the <b>DIFFERENT</b>; Next... <br />'; > } > } > } > > ------------------------ Yahoo! Groups Sponsor --------------------~--> Check out the new improvements in Yahoo! Groups email. http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/HKFolB/TM --------------------------------------------------------------------~-> Community email addresses: Post message: php-list@yahoogroups.com Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/