How to convert multiple arrays into Strings?-php Tutorial

Source: Internet
Author: User
Convert multiple arrays into strings. at the end of this post, mail163lc is used to edit the array $ aArray & nbsp; (& nbsp; [0] & nbsp; & gt; & nbsp; 1 & nbsp; [1] & nbsp; & gt; & nbsp; 2 & nbsp;) & nbsp; $ bArray & nbsp; (& nbsp; [0] & nbsp; & convert multiple arrays into strings

This post was last edited by mail163lc at 11:55:19

Array

$a=Array ( [0] => 1 [1] => 2 )
$b=Array ( [0] => 1 [1] => 2 )
$c=Array ( [0] => 128 [1] => 108 )
$d=Array ( [0] => 128 [1] => 216 )



String to be converted
$ E = 1 | 1 | 128 | 128 | ~ 2 | 2 | 108 | 216

The array may also contain

$a=Array ( [0] => 1 [1] => 2 [2] => 3 )
$b=Array ( [0] => 1 [1] => 2 [2] => 2 )
$c=Array ( [0] => 128 [1] => 108 [2] => 420 )
$d=Array ( [0] => 128 [1] => 216 [2] => 840 )


The conversion result requires programming.
$ E = 1 | 1 | 128 | 128 | ~ 2 | 2 | 108 | 216 | ~ 3 | 2 | 420 | 840


------ Solution --------------------
$ A = Array (0 => 1, 1 => 2, 2 => 3 );
$ B = Array (0 => 1, 1 => 2, 2 => 2 );
$ C = Array (0 => 128, 1 => 108, 2 => 420 );
$ D = Array (0 => 128, 1 => 216, 2 => 840 );

Echo foo ($ a, $ B, $ c, $ d );

Function foo (){
Foreach (func_get_args () as $ t ){
Foreach ($ t as $ I => $ v)
$ R [$ I] [] = $ v;
}
Foreach ($ r as $ I => $ v)
$ R [$ I] = join ('
------ Solution --------------------
', $ V );
Return join ('
------ Solution --------------------
~ ', $ R );
}
1
------ Solution --------------------
1
------ Solution --------------------
128
------ Solution --------------------
128
------ Solution --------------------
~ 2
------ Solution --------------------
2
------ Solution --------------------
108
------ Solution --------------------
216
------ Solution --------------------
~ 3
------ Solution --------------------
2
------ Solution --------------------
420
------ Solution --------------------
840

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.