Page 1 of 1

How to display two diferent text styles by Loop

Posted: Sun May 23, 2004 9:33 am
by yosuke_
Hi!
I know topic name sounds stupid, but how can I display something like this:
0
1
2
3
4

Here is my code:

Code: Select all

<?php
for($i=0;$i<10;$i++){
$x = 0;
if($x == 0){
echo "$i<br>";
$x++;
}
else 
{
echo "<b>$i</b><br>";
$x--;
}
}
?>
This is the result:
0
1
2
3
4
This is the result I need:
0
1
2
3
4
Please help me! Thank you!

Posted: Sun May 23, 2004 9:39 am
by kettle_drum

Code: Select all

for($x=0;$x<5;$x++){
   if($x%2){
      echo "<b>$x</b><br />";
   }else{
      echo $x."<br />";
   }
}

Posted: Sun May 23, 2004 9:39 am
by launchcode

Code: Select all

<?php
	$bold = true;
	for ($i = 0; $i < 20; $i++)
	{
		if ($bold)
		{
			echo "<b>$i</b><br>";
			$bold = false;
		}
		else
		{
			echo "$i<br>";
			$bold = true;
		}
	}
?>

Posted: Sun May 23, 2004 10:00 am
by yosuke_
Thank you bouth very much!!! :wink: