I'm working with symfony2, and i really don't understand what's happen with this. i have a == test, who don't return true when he should !At the very first iteration of that foreach, the == 's for test answer one time true, but after the first foreach iteration he don't find the other match... I had tried a lot of var_dump, and the var_dump say that: $service->getId() is int(24), and $discountsID is int(24), but the == test isn't true.
So help me, i'm pretty noob with php, and i really don't get what's happen there..
foreach ($services as $service) {
for ($i = 0; $i < count($discountsID); ++$i) {
if ($service->getId() == $discountsID[$i]) { //the fail test..
$bool = $discounts[$i]->getId();
} else {
$bool = -1;
}
}
$view_data['services'][] = array(
'discountId' => bool,
);
}