PHP Array Conversion related issues

Source: Internet
Author: User
PHP Array Conversion problem
How to Put

Array
(
[Strwarenum] = = Array
(
[0] = 1
[1] = 1
)

[Strwareid] = = Array
(
[0] = 80
[1] = 79
)

)


Converted to


Array
(

[Strwareid] =, 78,80
[Strwarenum] =,



)

And can be called separately. PHP


------Solution--------------------
Set your original array to $ A, and build an empty array that you need to include all the keys $b (your example some keys are not in $ A, so build separately)
I don't know about you. +Where does this value come from, for the time being when you're hitting 79 wrong
I am too lazy to write the assignment part, but also to change your code, trouble, write it Yourself
foreach ($b as $k = = $v) {
$a [$k][]= ';
$v =array_reverse ($a [$k]);
}
Var_export ($b);

Self test
------Solution--------------------
$arr = your array;
foreach ($arr as & $v) {
if (Is_array ($v)) $v = ', '. Join (', ', $v);
}
Print_r ($arr);
  • 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.