从数组中获取密钥及其值的最佳方法,仅在其他数组中与其密钥相比较(Best way to get keys and its values from an array which are not existent in another array compared only by its keys)
嗨我希望在与另一个阵列比较时过滤掉一些键和值。 “内容”对应该显示在最后...任何帮助非常感谢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 ?>hi I wanted to have some keys and values filtered out when compared with another array. The "content" pair should be displayed at the end...Any help is greatly appreciated THX alot!
<?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 ?>最满意答案
这有效:
$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; } }This works:
$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; } }更多推荐
发布评论