I have Drupal 7
site. I have the following Switch structure.
$day = (int)$node->field_hours_count[LANGUAGE_NONE][0]['value'];
switch ($day) {
case 1:
constructNode($node,"sunday");
echo 'node updated successfuly';
break;
case 2:
constructNode($node,"monday");
echo 'node updated successfuly';
break;
case 3:
constructNode($node,"tuesday");
echo 'node updated successfuly';
break;
default :
echo 'no node found';
exit();
}
Here constructNode()
is a function which accepts two parameters.
function constructNode($node,$dayOfWeek)
{
//core operation
return $node;
}
Issue is suppose $day =1 then case 1
is executed plus default case. For every value of $day, default
case is getting executed.
php - version v 5.5.12
How do I prevent this?