I am still learning php and this is how i convert php loop statement output to variable::
ob_start();
if 2 > 1 {
echo 'It is OK';
} else {
echo 'It is not OK';
}
$myvar = ob_get_clean();
echo $myvar;
Now the $myvar will output above if result, but is there better approach in doing this?