Array
(
X=> Array (0,01,02,... 0x),
Y=> Array (0,11,12,... 1x),
...
N=> Array (0,n1,n2,... NX),
)
The length of each value in the array is known to be the same, such as: Array[x] and Array[y] two arrays of equal length
I want to add 2 more keys Array[a] and array[b], to become
Array
(
X=> Array (0,01,02,... 0x),
Y=> Array (0,11,12,... 1x),
...
N=> Array (0,n1,n2,... NX),
A=> Array (a,a,a,... b),
B=> Array (b,b,b,... b),
)
Is there any good way to do that?
(I just want to get all the keys first, and then get the value length of the 1th key.) And then populate Array[a] and Array[b])
Reply to discussion (solution)
In fact, you want to add a key to the array so that the value of the key is the same length as the value of the other key.
The same length, that value.
Values are not the same, just have the same number of keys
Array (0,01,02,... 0x),
Array (0,11,12,... 1x),
For example: Count out is 10
The same length, that value.
However, the newly added 2 array values are the same
A=> Array (A,a,a,... a),
B=> Array (b,b,b,... b),
$ar = your array, $c =count ($ar [' X ']), $ar [' A ']=array_fill (0, $c, "a");p Rint_r ($ar);