JustinH
12-08-2002, 05:56 AM
Dunno if I'm doing something wrong or what...
here's the code:
// Doesn't work
if ($array1['val'] == $array2['val']) {
echo "Correct";
} else {
echo "Wrong";
}
// Does work
$var1 = $array1['val'];
$var2 = $array2['val'];
if ($var1 == $var2) {
echo "Correct";
}
As you can see they both have the same values, but for some reason when I try to do it as an assoc. array it returns false... any ideas? Isn't that veird?
Lippy
12-08-2002, 07:37 AM
I assume val could be one of two things. Either a Variable or a set term. If its meant to be a variable it needs a $ infront ot it. If it not meant to be a variable then I can't answer your question as my php knownledge is limited due to the fact I am still learning it myself.
MarkIL
12-08-2002, 08:07 AM
Try doing a
printf("Check: %s == %s?\n",$arr1['val'],$arr2['val']);
before the comparison.
JustinH
12-08-2002, 04:22 PM
eval("\$ticket[status] = \"$settings[default_closed]\";");
Those are the "real" array names... and it evals true. I must have a screw up somewhere else :confused:
JustinH
12-08-2002, 04:38 PM
n/m found the problem :p... I somehow had it in a loop so $ticket['status'] kept on getting closed appended to it so it was actually
ClosedClosedClosed == Closed :p.
Kyndig
12-08-2002, 08:14 PM
Use the in_array function (http://www.php.net/in_array) function for the above query.
JustinH
12-08-2002, 11:03 PM
Nope... in_array() only works if you wan't to fine the value ANYWHERE in the array. In my case I only wan't the two above keys to equal.
Furthermore, in_array() requires that the needle be a string, not an array, so even if I wanted to find it anywhere in the array it'd require more code:
if (in_array("val", $array) && in_array("val", $array2)) {
// Much better for my purpose:
if ($array['key'] == $array2['key']) {