$array = array(1,2,3,4,5); $array[0] = array(a,b,c,d,e,f,g); $array[1] = array(A,B,C,D,E,F,G);
I want to get an array (1,2,3,4,5); How is the value of this one-dimensional array obtained?
I get it this way: $array [0] but no, the impression seems to be java,c.
PHP is a beginner, currently this cock is trying to turn from the front to the background;
Reply content:
$array = array(1,2,3,4,5); $array[0] = array(a,b,c,d,e,f,g); $array[1] = array(A,B,C,D,E,F,G);
I want to get an array (1,2,3,4,5); How is the value of this one-dimensional array obtained?
I get it this way: $array [0] but no, the impression seems to be java,c.
PHP is a beginner, currently this cock is trying to turn from the front to the background;
var_dump($array);
Just call it and see it.
php
$array = array(1,2,3,4,5);
When you assign a value like this, it's actually the equivalent of an array (0=>1, 1=>2, 3=>4, 4=>5);
When you do not specify a key (or subscript), it is automatically initialized and incremented by 0.
Then you give $array[0] an array of assignments that will become
php
array(0=>array(a,b,c,d,e,f,g), 1=>2, 3=>4, 4=>5);
That is to say that the original 1 has become an array, so you cannot get to array (1,2,3,4,5), because the original value has been changed by you.
You want to traverse can write like this:
php
foreach($arr as $var) { print_r($var);}