Each value in the known quantity group is the same length, how to add a key key?

Source: Internet
Author: User
Each value in the known quantity group is the same length, how do you add a key?
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])

Share to:


------Solution--------------------

$ar = your array;
$c =count ($ar [' X ']);
$ar [' A ']=array_fill (0, $c, "a");
Print_r ($ar);
  • 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.