dailybird
3/31/2017 - 12:10 PM

Print a pyramid.

Print a pyramid.

<?php 

/**
 * 打印金字塔
 * @param  [int] $level [层数]
 * @return [void]  
 */
function pyramidPrinter($level){
	for ($index = 1; $index <= $level; $index++) {
		for ($space = $level; $space > $index; $space--) {
			echo "<span style='color:#fff;'>*</span>";
		}
		
		for ($star = 1; $star <= $index * 2 - 1; $star++) {
			echo "<span>*</span>";
		}
		
		for ($space = $level; $space > $index; $space--) {
			echo "<span style='color:#fff;'>*</span>";
		}
		echo "<br>";
	}	
}