我试图列出所有逗号分隔的值。 <?php $records = [ ["WLP001","Cream Ale,Dusseldorf Altbier,Kolsch,Ordinary Bitter"], ["WLP002","American Amber,American Brown Ale,American India Pale Ale,American Pale Ale,American Porter,Apple Wine,Barleywine Ale,Common Perry,Cream Ale,Dusseldorf Altbier,English Brown Ale,English Cider,English India Pale Ale,English Old Ale,English Pale Ale,Extra Special Bitter,Foreign Export Stout,French Cider,Irish Dry Stout,Irish Red Ale,Kolsch,Oatmeal Stout,Ordinary Bitter,Scotch Ale (Wee Heavy),Sweet Stout,Wheat Ale"],]; for ($i=0; $i < count($records); $i++) { $styles = explode(',',$records[$i][1]); echo $styles[0]."<br>"; } ?>例如对于“WLP001” 和“WLP002” Cream Ale, Dusseldorf Altbier, Kolsch, Ordinary Bitter, American Amber, American Brown Ale, American India Pale Ale,只要数据以逗号分隔,它就会继续其余部分。因为现在的输出是
1 回答
翻翻过去那场雪
TA贡献2065条经验 获得超14个赞
由于样式可以包含多个元素,因此您需要对其进行循环并回显每个元素,而不仅仅是第一个元素。
for ($i=0; $i < count($records); $i++) {
$styles = explode(',',$records[$i][1]);
for ($j=0; $j < count($styles); $j++) {
echo $styles[$j]."<br>";
}
}
- 1 回答
- 0 关注
- 87 浏览
添加回答
举报
0/150
提交
取消