duanhao7786 2015-11-20 10:19
浏览 18

PHP组合数组用于过滤器

I have two arrays and both of them are sorted by the 'hostid'. Now I'm filtering the first array with the values, so I can get every value that is less than 10. The values that are more than 10 are now out of the array. Now I want to do exactly the same with the second array because I need only the Names with the same 'hostid' like the filtered array. But the second array has only names and I do not know how to filter that it has also only the items with the same 'hostid' as the filtered array.

So this are the two arrays:

Array 1: $filtered = array_filter($names1, function ($x) { return $x <= 15; });

Output: {"0":"8.4112","2":"9.5231","3":"9.0655","4":"7.8400","5":"13.2712","6":"12.2458","9":"8.1954","13":"12.8633"}

Array 2: $nameserver = array();

Output: ('["name1","name2",... ]')

Is there a way to filter the same hostids from the second array as I did from the first? I already tried to combine them, but that did not work.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度