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
Share on other sites

Users will not post their homework questions expecting to get their homework coded for them. If you have a question about part of the assignment that you do not understand' date=' please post asking for an explanation rather than the code.[/quote']
Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.