我不能通过foreach将任何内容分配给php中的数组,任何想法? [英] I can't assign anything to an array in php through foreach, any idea?
本文介绍了我不能通过foreach将任何内容分配给php中的数组,任何想法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的页面中连续创建三个表格。将这些值放入,我尝试在回显它们之后删除每个值,但我不能删除$ Column [$ key]的值我使用三种方式但它们不起作用。现在我的问题是为什么?我该怎么办?
还有更好的方法吗?
<?php
$ i = 0 ;
while(count($ TBClm)> 0)
{?>
< div class = col-25p >
< 表 >
< tbody >
<? php
$ j = 0 跨度>;
foreach ($ TBClm as $ Ctg => $ Column)
{
++ $ j;
?>
< tr class = 类别 >
< td > - <? php echo $ Ctg ; ?> - < / td >
< / tr >
& lt;? php
foreach ($ Column as $ key => $ values
{
if($ Column [$ key] == null)
continue ;
++ $ j;
?>
< tr >
< td >
<? echo $ values [0]; ?>
< td >
< / tr >
< ;? php
$ Column [$ key] = null; // 实际上我想删除这部分
// 我使用了unset()和array_shift()但它们没有工作
if ($ j> 10)
break ;
}
if ($ j> 10)
break ;
未设置($ TBClm [$ Ctg]);
} ?>
< / tbody >
< / table >
< / div >
<? php
} ?>
解决方案
列
key]我用三种方法但它们不起作用。现在我的问题是为什么?我该怎么办?
还有更好的方法吗?
<?php
i = 0 ;
while(count(
I want to create three table in a row in my page & put these values in, I try to remove each value after echoing them but i cant remove the value of $Column[$key] i used three way but they don't work. now my question is why? and how can i do that?
Is there any better way?
<?php
$i = 0;
while(count($TBClm)>0)
{?>
<div class="col-25p">
<table>
<tbody>
<?php
$j = 0;
foreach ($TBClm as $Ctg => $Column)
{
++$j;
?>
<tr class="category">
<td>-<?php echo $Ctg;?>-</td>
</tr>
<?php
foreach ($Column as $key => $values)
{
if($Column[$key]==null)
continue;
++$j;
?>
<tr>
<td>
<?echo $values[0];?>
<td>
</tr>
<?php
$Column[$key]=null;//actually i want to remove this part
//I used unset() and array_shift() but they didn't work
if ($j > 10)
break;
}
if ($j > 10)
break;
unset($TBClm[$Ctg]);
}?>
</tbody>
</table>
</div>
<?php
}?>
解决方案
Column
key] i used three way but they don't work. now my question is why? and how can i do that?
Is there any better way?
<?php
i = 0; while(count(
这篇关于我不能通过foreach将任何内容分配给php中的数组,任何想法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文