mayman212 Posted November 1, 2011 Share Posted November 1, 2011 Hi all I am trying to print a pattern shown below: 1 23 456 7891011 1213141516 17181920 212223 2425 26 Any know how to do it? I'm a bit stuck, I completed it with asterix. Quote Link to comment https://forums.phpfreaks.com/topic/250239-number-diamond/ Share on other sites More sharing options...
mayman212 Posted November 1, 2011 Author Share Posted November 1, 2011 <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. Quote Link to comment https://forums.phpfreaks.com/topic/250239-number-diamond/#findComment-1284002 Share on other sites More sharing options...
Adam Posted November 1, 2011 Share Posted November 1, 2011 Is this homework? Quote Link to comment https://forums.phpfreaks.com/topic/250239-number-diamond/#findComment-1284010 Share on other sites More sharing options...
mayman212 Posted November 1, 2011 Author Share Posted November 1, 2011 yeah are you going to give me an idea? Quote Link to comment https://forums.phpfreaks.com/topic/250239-number-diamond/#findComment-1284011 Share on other sites More sharing options...
Adam Posted November 1, 2011 Share Posted November 1, 2011 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'] Quote Link to comment https://forums.phpfreaks.com/topic/250239-number-diamond/#findComment-1284013 Share on other sites More sharing options...
mayman212 Posted November 1, 2011 Author Share Posted November 1, 2011 I asked for help, not how to do it. Quote Link to comment https://forums.phpfreaks.com/topic/250239-number-diamond/#findComment-1284014 Share on other sites More sharing options...
Adam Posted November 1, 2011 Share Posted November 1, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/250239-number-diamond/#findComment-1284017 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.