Questions about the word group

Source: Internet
Author: User
Excuse me


$test = Array ();
Function ABC ($port, $index = 0) {
if (!isset ($GLOBALS [' Test '] [$index]))
$GLOBALS [' Test '] [$index] = array ();
$GLOBALS [' Test '] [$index] [] = $port;
}

?>

I would like to ask the above code and originally defined outside the function test is a one-dimensional array,
But $globals[' test ' [$index] [] = $port; This way, test becomes a 2-dimensional array.
So can you understand how many of the data in a row of this array has $port decision, that is, if the $port is 3, then this
One row of an array is three data. Is that right? A friend of the trouble will help to reply, thank you


Reply to discussion (solution)

An array of PHP is not an array in the traditional sense
The concept of rows and columns can be Emily just only when it is a two-dimensional array

An array of PHP is not an array in the traditional sense
The concept of rows and columns can be Emily just only when it is a two-dimensional array



Thank you xuzuning Moderator's reply

Also want to ask under so $GLOBALS [' test '] [$index] [] = $port; How should this sentence be understood?

$GLOBALS [' Test '] [$index] [] = $port;
Equals
Array_push ($GLOBALS [' Test '] [$index], $port);

$GLOBALS [' Test '] [$index] [] = $port;
Equals
Array_push ($GLOBALS [' Test '] [$index], $port);



Thank you Fdipzone Moderator's reply

But there are some places I don't quite understand.

For example $port = 1;
Then when running $GLOBALS [' Test '] [$index] [] = $port, then $GLOBALS [' Test '] [$index] []
$GLOBALS [' Test '] [$index] [0] is 1, is that so? That means it's a 2-dimensional array. Or can it be understood that it is 2 for an array?


$GLOBALS [' Test '] [$index] [] = $port;
Equals
Array_push ($GLOBALS [' Test '] [$index], $port);



Thank you Fdipzone Moderator's reply

But there are some places I don't quite understand.

For example $port = 1;
Then when running $GLOBALS [' Test '] [$index] [] = $port, then $GLOBALS [' Test '] [$index] []
$GLOBALS [' Test '] [$index] [0] is 1, is that so? That means it's a 2-dimensional array. Or can it be understood that it is 2 for an array?



Yes, you print_r print it out and see it.
$GLOBALS [' Test '] [$index] [0] In fact, this is already a multidimensional number of feet.

I have a knack for making simple things complicated.

$test = Array ();
$port = 1;

$GLOBALS [' Test '] [$index] [] = $port;
Append the $port to the array $GLOBALS [' Test '] [$index]
Append $port to Array $test [$index]
Upon completion
$GLOBALS [' Test '] is a 3-D array
$test is a 2-D array

The reason that PHP's array is not an array of traditional meaning is because the array is homogeneous, that is, the number of columns per row is the same
and the array of PHP does not have this constraint array (array (4), array)
Additionally, the value of the position of the array element is marked consecutively, and the array of PHP does not have this constraint array (3 = = Array (8 = 4)
You can also use the name (association key) to mark an array (' c ' = = Array (4))

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