我的两个数组值是
1)
Array (
[0] => School Children
[1] => Vocational Training Centre
[2] => Admission Fee
)
2) 入场费
Array (
[0] => School Children
[1] => World Ten K
[2] => Vocational Training Centre
[3] => Van travel
[4] => Admission Fee
)
在这里,它们的键不同,如果两者都在计算,则仅选中我的复选框,否则不会选中它们。
我尝试过使用array_search
但没有用,还有一些情况in_array
。
$main
对于所有值,并且$temp_imp
是来自数据库的值
<?php
$i=0;
foreach($prj_data as $prj_pop){
$main[]=$prj_pop->name;
?>
<br/><br/>
<input type="checkbox" class="checkbox_project" value="<?php echo $prj_pop->name;?>"
<?php
if (array_intersect($temp_imp, $main))
{
echo 'checked="true"';
}
?>
<?php
echo $prj_pop->name;
$i++;
}
?>