i have a simple json array. in which i have two objects. now i am checking it for some specific values , if found do some thing , if not found do another thing. But i dont know why if condition runs both blocks. true and false both blocks are executed. please help.
$jsonstring = '{"like":[{"username":"abc","password":"abc"},{"username":"def","password":"def"}]}';
$jsonarr = json_decode($jsonstring);
$count = count($jsonarr->like);
for ($r = 0; $r < $count; $r++)
{
if ($jsonarr->like[$r]->username == 'abc' && $jsonarr->like[$r]->password == 'abc')
{
echo 'Match';
}else
{
echo 'No Match';
}
}
is it not like regular if condition ?