PHP uses Array_fill to define multidimensional array methods _php Tutorial

Source: Internet
Author: User

PHP uses Array_fill to define multidimensional array methods


This article mainly introduces the method that PHP uses Array_fill to define multidimensional array, the example analyzes the use skill of array_fill function in PHP, has certain reference value, need friend can refer to the next

This example describes how PHP uses Array_fill to define multidimensional arrays. Share to everyone for your reference. The specific analysis is as follows:

Multiple Array_fill can be nested in PHP to complete the definition of a multidimensional array:

?

1

$creation =array_fill (0,3,array_fill (0,2,null));

The following statements can be used to populate:

?

1

2

3

4

5

6

7

$ABC = 0;

for ($i =0; $i <3; $i + +) {

for ($j =0; $j <2; $j + +) {

$ABC = $abc +1;

$creation [$i] [$j]= $abc;

}

}

The result is:

?

1

2

3

4

5

6

Array

(

[0] = = Array ([0] = 1 [1] = 2)

[1] = = Array ([0] = 3 [1] = 4)

[2] = = Array ([0] = 5 [1] = 6)

)

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/969965.html www.bkjia.com true http://www.bkjia.com/PHPjc/969965.html techarticle PHP uses Array_fill to define multidimensional arrays this article mainly introduces the method of using Array_fill to define the multidimensional array, the example analyzes the use of Array_fill function in PHP, with a ...

  • 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.