嗨我希望在与另一个数组比较时过滤掉一些键和值。 “内容”对应该显示在最后......任何帮助都非常感谢THX很多!
<?php
$test = array(
['slideid'] => 597,
['token'] =>'4e23fdd176372984870a9c65db7133b5',
['content'] =>'<p>sdg</p>',
)
$test2 = array(
['slideid'] => "",
['token'] =>""
)
foreach ($test not in $test2){
print $test2
} //not working of course
?>
答案 0 :(得分:2)
这有效:
$test = array(
'slideid' => 597,
'token' =>'4e23fdd176372984870a9c65db7133b5',
'content' =>'<p>sdg</p>'
);
$test2 = array(
'slideid' => "",
'token' =>""
);
foreach ($test as $key => $value){
if (!array_key_exists($key, $test2)) {
echo $value;
}
}
答案 1 :(得分:2)
$arr
包含test
但不是test2
$arr = array_diff(array_keys($test), array_keys($test2));
print_r($arr);