Jump to content

number diamond


mayman212

Recommended Posts

<table>
<tr>
<td align="center">
<?PHP

$b = 1;
for ($a=1; $a<=10; $a++)
{
        echo str_repeat('*', $b);
        $b++;
        echo "<br>";
}
$b = 9;
for ($a=1; $a<=9; $a++)
{
        echo str_repeat('*', $b);
        $b--;
        echo "<br>";
}
?>
</td>
</tr>
</table>

 

this is the code for the asterix shape.

Link to comment
https://forums.phpfreaks.com/topic/250239-number-diamond/#findComment-1284002
Share on other sites

Any know how to do it?

 

You asked how it's done. Unfortunately there's no well-known or documented solution for something like this- it's completely abstract and designed to get you thinking. Anyone here would need to sit down for at least a short period of time and have a think how to do it, which is what you should be doing. By all means if you get stuck with a coding issue or are close to finishing but can't work out a particular part, come back. I'm not trying to be a dick either, it's in your own interest to try and figure it out yourself.

Link to comment
https://forums.phpfreaks.com/topic/250239-number-diamond/#findComment-1284017
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.