我正在尝试为我的控制器创建一些东西,以便在页面中生成输入,textarea。
$application = array(
'table' => "teste",
'titulo_pt' => true,
'titulo_en' => true,
'desc_pt' => true,
'desc_en' => true,
);
这是我的阵列,我现在正在做的是:
foreach($application as $key=>$value){
if($key == "titulo_pt"){
echo "NEW INPUT";
}
}
我需要帮助的是计算有多少例如“titulo_pt”,我需要能够计算它并且数组计数不起作用。另外,我需要为每个回显和数组中的新输入一样多,因为如果我再向数组添加1个“titulo_pt”,它会将它们合并到print_r中,只需回显1个新输入
发布于 2018-08-13 19:02:35
你只能在数组中使用唯一键。这就是为什么你只看到1 titulo_pt
在你的print_r()
。
也许一种方法是将每个字段中的多少个存储为计数,如下所示:
$application = array(
'table' => "teste",
'titulo_pt' => 2,
'titulo_en' => 1,
'desc_pt' => 1,
'desc_en' => 1,
);
https://stackoverflow.com/questions/-100002116
复制相似问题