How to use array_fill to define multi-dimensional arrays in PHP _ PHP Tutorial

Source: Internet
Author: User
PHP uses array_fill to define multi-dimensional arrays. PHP uses array_fill to define multi-dimensional arrays. This article mainly introduces how PHP uses array_fill to define multi-dimensional arrays. The example shows how to use the array_fill function in php, has a PHP method to define multi-dimensional arrays using array_fill

This article describes how to use array_fill to define multi-dimensional arrays in PHP. The example shows how to use the array_fill function in php. it has some reference value. For more information, see

This example describes how PHP uses array_fill to define multi-dimensional arrays. Share it with you for your reference. The specific analysis is as follows:

In PHP, multiple array_fill nesting can be used to define multi-dimensional arrays:

?

1

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

You can fill in the following statement:

?

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;

}

}

Result:

?

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 will help you with php programming.

This article describes how to use array_fill to define multi-dimensional arrays in PHP. The example shows how to use the array_fill function in php...

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.