I want to make a series, e.g, 1/2 + 3/4 + 5/6 + 7/8 + 9/10 + 11/12 as a string using loops in php. write now i have written this code:
$output=''; for ($i=0; $i < 6; $i++) { $output=$output.($i+1+$i).'/'.($i+2+$i); if ($i==5) { break; } else { $output=$output.'+'; } } echo nl2br("\n4: $output"); output:
1/2 + 3/4 + 5/6 + 7/8 + 9/10 + 11/12 is there any other better approach to do that?
