How to write this without goto:
ob_start();
$a = 0;
echo "START of LEFT<br />";
begin:
if($a > 0) {
echo "CONTENT LEFT: $a<BR />";
<VERY DIFFICULT ALGORHITM>
goto end;
}
<... ALL THE REST CODE OF LEFT ...>
echo "END of LEFT<br /><br />";
$output1 = ob_get_contents();
ob_end_clean();
ob_start();
echo "START of CENTER<br />";
$a = 5; goto begin;
end:
<... ALL THE REST CODE OF CENTER ...>
echo "END of CENTER<br />";
$output2 = ob_get_contents();
ob_end_clean();
// print it
echo $output1.$output2;
To get this echo:
START of LEFT
CONTENT LEFT: 5
END of LEFT
START of CENTER
END of CENTER
Requirements:
1. I m not allowed to change the order(CORE( echo $a ), and PLUGIN( $a=5 )):
ob_start();
$a = 0;
<ANY CODE>
echo $a;
$output1 = ob_get_contents();
ob_end_clean();
ob_start();
<ANY CODE>
$a = rand(0,10);
$output2 = ob_get_contents();
ob_end_clean();
2. Output must be generated via ob_get_contents();
But I m allowed to write ANY CODE in places.
// Solvings ob_get_contents(); Helps only if want to replace few lines in output HTML CODE, but can t change a value of variable, to change the ALGORHYTM(depends of var value), which generates the random HTML code.
Also, As I checked my code, I understand, that my code, even with GOTO labels statement , DOES NOT going to change the $output1 content ?. How to do that? Is the only way is to recache the $output1 from his beggining. Or maybe I m able to do this in other ways?