小编Mui*_*ter的帖子

PHP foreach循环遍历多维数组

我有一个多维数组,我该如何使用它?我想在for循环中使用每个单独的数组.

我想要实现的是能够将每个部分放在我的数据库中,就像在db no中输入一样.在db no中0 - > 1和4条目.db - 1中的1 - > 5和6条目.2 - > 1和4以及5和6

我有这个代码:

<?php 
    print_r($calculatie_id); 
    for ($i=0; $i<=3; $i++) 
{ 
?>  
<tr> 
    <td> 

    <?php 
    foreach ($calculatie_id[$i] as $value) 
    { 
        echo $value; 
    } 
?>

print_r($calculatie_id); gives 
Array ( [0] => Array ( [0] => 4 [1] => 6 ) [1] => Array ( [0] => 1 [1] => 5 ) [2] => Array ( [0] => 5 [1] => 6 ) [3] => )
Run Code Online (Sandbox Code Playgroud)

但是在使用时foreach …

php foreach for-loop

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

for-loop ×1

foreach ×1

php ×1