I am trying to generate final string to show users based on some conditions.
$flag=0;
$var='Please ';
if($user->is_details_updated == 'N' && $user->needs_to_update_details == "Y")
{
$var='update your profile details';
$flag=1;
}
if ($flag ==1)
{
$var=' and ';
}
if($user->is_pass_changed == 'N' && $user->needs_to_update_password == "Y")
{
$var.='change password';
}
So, If all three if return true then final $var looks like this:
Please update your profile details and change password
How this can be written better?
You can add messages to array and then join them with
and