PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am comparing 2 strings that are being returned from arrays, and i want the if statement to execute if the strings are different. In this code snip this particular IF statement should only be true 4 times, but it keeps geting entered somehow. What am i doing wrong here? I tried != , !==, and now im doing strcmp. Here is the code
if($string1 == $string2) { //if string1 is the same as string2 then
//execute something
}
if($string1 != $string2) { //if string1 is not the same as string2 then
//execute something
}
Yeah that is typical of the kind of stuff I would try and do when I first started learning PHP from a C++ background (even if it was a short one).
Generally ZeroFear in PHP things are much easier xD there are loada functions that mean you don't have to reinvent the wheel and the arrays are really powerful.
First thing I recommend is to echo out the array vals before any comparisons as a test just to see if the values coming into your comparison are what you expect. If they are the values you expect, then the next step is determining the logic to write the proper comparisons.