我有一个包含ID和URL的多维数组。我想只输出网址。
$abstract_details = array(
array(
'id' => 68769782222,
'url' => 'http://yourclick.ch'
),
array(
'id' => 111,
'url' => 'http://google.com'
)
);
foreach ($abstract_details as $abstract_detail) {
foreach ($abstract_detail as $get_abstract_detail) {
$result .= $get_abstract_detail . '<br>';
}
}
当我运行我的代码时,我得到了两个信息。如何控制我想要展示的内容?
答案 0 :(得分:11)
使用array_column
阻止你进行foreach循环
For z = 3 To LstSpecCol
R_counter = 0
C_counter = 0
If (WS_Sel.AutoFilterMode And WS_Sel.FilterMode) Or WS_Sel.FilterMode Then
WS_.ShowAllData
End If
WS_Sel.Range(WS_Sel.Cells(1, 1), WS_Sel.Cells(counter + 1, LstCol1)).AutoFilter _
Field:=z, Criteria1:="Yes"
With WS_Sel
Set rngFilter_Yes = Intersect(.UsedRange, .UsedRange.Offset(1), _
.Columns(z)).SpecialCells(xlCellTypeVisible)
LstRow_Yes = rngFilter_Yes.Cells.Count
End With
For t = 2 To LstRow_Yes
If WS_Sel.Cells(t, 2) = "R" Then
R_counter = R_counter + 1
Else
C_counter = C_counter + 1
End If
Next t
Next z
答案 1 :(得分:2)
foreach ($abstract_details as $abstract_detail) {
$result .= $abstract_detail['url']
}
答案 2 :(得分:2)
如果你只想打印网址,你甚至不需要嵌套循环。试试这个:
foreach ($abstract_details as $abstract_detail) {
$result .= $abstract_detail['url'] . '<br>';
}
输出:
http://yourclick.ch
http://google.com