An array of PHP learning

Source: Internet
Author: User

This article to share the content of PHP in the knowledge of the array, the need for friends can refer to

Array what's not very simple
int a[1100000]
But that's not what PHP is.

<?php    $n =1;    $a =array (array ());    $s =array ();    $s [1]= "S30408";    $a [1][1][1]=0; $a [1][1][2]=1.05;    $a [1][2][1]=0; $a [1][2][2]=2.04;    $a [1][3][1]=7.90; $a [1][3][2]=11.15;    $a [1][4][1]=17.80; $a [1][4][2]=20.20;    $a [1][5][1]=0; $a [1][5][2]=0.09;    $a [1][6][1]=0; $a [1][6][2]=0.055;    $a [1][7][1]=0; $a [1][7][2]=0.035;? >

This is a three-dimensional array, isn't it some trouble?
Let's talk about one-dimensional arrays.

<?php    $s =array ();/* Each array is a dimension */    $s [1]=100; $s [2]=200;    Echo $s [1]+ $s [2];? >


This is the array. I have a full array of PHP

<?php    $v =array ();    $a =array ();    function Dfs ($k) {        Global $v, $a, $n;        if ($k = = $n + 1) {for            ($i =1; $i <n; $i + +) {                echo $v [$i], "";            }            echo $v [$n], "<br>";        }        else{for            ($i =1; $i <=n; $i + +) {                if ($v [$i]==true) {                    $v [$i]=false;                    $a [$k]= $i;                    DFS ($k + 1);                    $v [$i]=true;    }}} DFS (5);? >

This is the full array of 5.
It seems a bit wrong, but not afraid.
Just look at the examples.
The two-dimensional connection is simple.
It is

$s =array (array ());

That's it.
What about tomorrow's chapter?
Let's talk about some arithmetic loops.

Array what's not very simple
int a[1100000]
But that's not what PHP is.

<?php    $n =1;    $a =array (array ());    $s =array ();    $s [1]= "S30408";    $a [1][1][1]=0; $a [1][1][2]=1.05;    $a [1][2][1]=0; $a [1][2][2]=2.04;    $a [1][3][1]=7.90; $a [1][3][2]=11.15;    $a [1][4][1]=17.80; $a [1][4][2]=20.20;    $a [1][5][1]=0; $a [1][5][2]=0.09;    $a [1][6][1]=0; $a [1][6][2]=0.055;    $a [1][7][1]=0; $a [1][7][2]=0.035;? >

This is a three-dimensional array, isn't it some trouble?
Let's talk about one-dimensional arrays.

<?php    $s =array ();/* Each array is a dimension */    $s [1]=100; $s [2]=200;    Echo $s [1]+ $s [2];? >


This is the array. I have a full array of PHP

<?php    $v =array ();    $a =array ();    function Dfs ($k) {        Global $v, $a, $n;        if ($k = = $n + 1) {for            ($i =1; $i <n; $i + +) {                echo $v [$i], "";            }            echo $v [$n], "<br>";        }        else{for            ($i =1; $i <=n; $i + +) {                if ($v [$i]==true) {                    $v [$i]=false;                    $a [$k]= $i;                    DFS ($k + 1);                    $v [$i]=true;    }}} DFS (5);? >

This is the full array of 5.
It seems a bit wrong, but not afraid.
Just look at the examples.
The two-dimensional connection is simple.
It is

$s =array (array ());

That's it.
What about tomorrow's chapter?
Let's talk about some arithmetic loops.

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.