从数组中获取密钥及其值的最佳方法,仅在其他数组中与其密钥相比较(Best way to get keys and its values from an array which are not exis

编程入门 行业动态 更新时间:2024-10-26 09:24:04
从数组中获取密钥及其值的最佳方法,仅在其他数组中与其密钥相比较(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; } }

更多推荐

本文发布于:2023-08-03 19:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1395733.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密钥   组中   相比较   方法   keys

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!