Comparing Data

    Date: 02/17/08 (PHP Community)    Keywords: database

    I have two arrays. one is data from a database, one is data from a form. If the data in the two arrays are the same, meaning no changes were made to the form, then I want to know so that a database update is not needed. If the data are different, then I want to not only update the database, but mark the time and date of the new update.

    Here's what I've come up with:
    $difference=array_diff($formdata, $dbdata);
    $num_diff=count($difference);
    if ($num_diff!=0){ update Database & set new date_updated }

    Might there be a more elegant way to do this?

    Source: http://community.livejournal.com/php/614320.html

« PHP Categories? || Freelancing »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home