php--Common Algorithm 3

Source: Internet
Author: User

<?php

function Leijia ($number) {
$arr =[];
for ($i =1; $i <= $number; $i + +)
{
for ($j =1; $j <= $number; $j + +)
{
$j ==1 is to let I cycle from 1 to 10 end
if ($j ==1) {
$arr [$i][]= $i;
Continue
}
$i ==1 is to let J's loop start from 1 to 10 end
if ($i ==1) {
$arr [$i][]= $j;
Continue
}
Var_dump ($arr [$i]);
The value of 2nd to nth of layer 2nd to Nth is the sum of the previous number of this layer and the number of the same column in the previous layer
$arr [$i][]= $arr [$i][count ($arr [$i]) -1]+ $arr [$i -1][count ($arr [$i])];
}
}

Output in PHP tabular format
echo "<table border=1>";
foreach ($arr as $key = $val)
{
echo "<tr>";
foreach ($val as $k = $v)
{
echo "<td>";
Echo $v;
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
}
Incoming numbers are the number of layers to accumulate
Leijia (10);
?>

The next step is to update the usage of the October CMS, or go to the code cloud to see what I have written on the Laravel framework URL: Https://gitee.com/lfm123456/zhiye

php--Common Algorithm 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.