--- In [email protected], 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 />';
> }
> }
> }
>
It looks like what you want is simply:
foreach ($_POST as $new){
foreach($olddata as $old) {
if ($new == $old) {
...etc.
The php_mysql group is dedicated to learn more about the PHP/MySQL web database
possibilities through group learning.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php_mysql/
<*> 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/