How does foreach process multiple arrays at the same time?
Source: Internet
Author: User
How can foreach process multiple arrays at the same time? for example, I have three arrays $ array_a $ array_ B $ array_c. my requirements are as follows: each foreach can output a foreach ($ array_aas $ a; $ array_bas $ B; $ array_cas $ c;) {echo $. & quot foreach how to process multiple arrays at the same time
For example, I have three arrays $ array_a $ array_ B $ array_c
My requirement is: each foreach can output an item of each array at the same time.
Similar to this
Foreach ($ array_a as $ a; $ array_ B as $ B; $ array_c as $ c ;){
Echo $ a. "". $ B. "". $ c;
}
Of course, the syntax in the brackets above foreach should be wrong. how should we implement it?
------ Solution --------------------
Doesn't foreach mean the same thing?
Foreach ($ array_a as $ k => $ v ){
Echo $ v. "". $ array_ B [$ k]. "". $ array_c [$ k]."
";
}
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