Example #1
0
            //run the loop upto number of lines
            for ($s = 1; $s <= $line - $i; ++$s) {
                // run the loop to set the space for pyramid
                echo " ";
            }
            if ($i == $line) {
                // run at the end of the line
                for ($s = 1; $s <= 2 * $line - 1; ++$s) {
                    echo "1";
                }
            } else {
                // run the loop based on the line number
                while ($a != 2 * $i - 1) {
                    echo ++$count;
                    ++$a;
                }
            }
            $a = 0;
            echo "\n";
            //for line break at the end of every main loop
        }
    }
    public function fortest()
    {
        $test = $this->pyramid();
        return true;
    }
}
$test = new test1();
echo $test->pyramid();