Return to Snippet

Revision: 51620
at September 29, 2011 20:35 by erraja_07


Initial Code
$c=1;
$n = 9;
for($i=1;$i<=$n;$i++)
{
	for($j=$i;$j<$n;$j++)
	{
		echo "&nbsp;&nbsp;";
	}
	for($k=1;$k<=$c;$k++)
	{
		if($k%2==0)
			echo "&nbsp;&nbsp;";
		else
			echo '*';
	}
	echo "<br />";
	$c+=2;
}
for($i=$n;$i>=1;$i--)
{
	for($j=$i;$j<$n;$j++)
	{
		echo "&nbsp;&nbsp;";
	}
	for($k=$c-1;$k>1;$k--)
	{
		if($k%2==0)
			echo "&nbsp;&nbsp;";
		else
			echo '*';
	}
	echo "<br />";
	$c-=2;
}

Initial URL

                                

Initial Description

                                

Initial Title
Code to Display Star Using PHP

Initial Tags

                                

Initial Language
PHP