[英]Looping through 3 arrays
how would I go about looping through this data here:我将如何在这里遍历这些数据:
Array (
[reply] => Array (
[recipient] => Array (
[@msisdn] => 1234123412
[@id] => 5b5f9635-15d7-44d8-b1e3-7015hj95c71c
)
)
)
So I want to get the @mssidn's and the @id's to use like this:所以我想让 @mssidn 和 @id 像这样使用:
foreach($$$){
$sqldata .= '(' . $last_id . ',' . $msisdn . ',' . $id . '),';
}
$last_id
comes from another function, so just need the two others. $last_id
来自另一个函数,所以只需要另外两个。 I just can't seem to get it working, so any help will be much appreciated.我似乎无法让它工作,所以任何帮助将不胜感激。
Simply iterate your array get the values by key @msisdn
and @id
只需迭代您的数组
@id
通过键@msisdn
和@id
获取值
foreach($array as $value) {
foreach($value as $data) {
$sqldata .= '(' . $last_id . ',' . $data['@msisdn'] . ',' . $data['@id'] . '),';
}
}
start the foreach loop at the point in the data structure that you want to process and just loop over the contents of the inner array在要处理的数据结构中的点处启动 foreach 循环,然后循环遍历内部数组的内容
foreach ($arr['reply'] as $recip){
$sqldata .= '(' . $last_id . ',' . $recip['@msisdn'] . ',' . $recip['@id'] . '),';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.