I have two arrays $oldInfo and $newInfo , where $oldInfo is the existing data from the database, and $newInfo is the information entered by the user. If one particular field is different between the two, I want to enter a new row into the database, if this one field matches the one I just update.
if($oldInfo['col'] != $newInfo['col']){ INSERT INTO ... } else { UPDATE WHERE ... }
The problem is that the if statement always evaluates to true. I put the echo ... die() command in the if statement to print two values, and they both look the same. Old Info: 38mg/1, 20 New Info: 38mg/1, 20
Is there anything specific about string comparisons in PHP? These values โโseem to be exactly the same (in fact, $ oldInfo is used to pre-fill the form, so they should be the same), but the if statement says that they do not match.
source share