Skip to content

Instantly share code, notes, and snippets.

@notian
Created November 25, 2016 19:45
Show Gist options
  • Save notian/5f98bd3185c7882dc638862f13406563 to your computer and use it in GitHub Desktop.
Save notian/5f98bd3185c7882dc638862f13406563 to your computer and use it in GitHub Desktop.
Diamond Table
<?php
function line($i){
$blank = '<td></td>';
$star = '<td>*</td>';
echo '<tr>'.
str_repeat($blank,5-$i).
str_repeat($star,($i*2)-1).
str_repeat($blank,5-$i).
'</tr>';
echo "\n";
}
for( $i = 1;$i < 6;$i++ ){
line($i);
}
for( $i = 4;$i > 0;$i-- ){
line($i);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment