dongzhong8691 2011-10-07 16:45
浏览 53
已采纳

PHP数组搜索 - key => string

I got some trouble with in_array()

$list = array(
    "files/" => "/system/application/files/_index.php",
    "misc/chat/" => "/system/application/misc/chat/_index.php"
);

I have this $_GET['f'] which holds the string files/.
How can I search through the array for possible matches?

If the string is found in the array, then the file should be included

Thanks for any help :)

  • 写回答

5条回答 默认 最新

  • douketangyouzh5219 2011-10-07 16:48
    关注

    array_key_exists is a function that returns true of the supplied key is in the array.

    if(array_key_exists( $_GET['f'], $list )) {
        echo $list[$_GET['f']];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 vue3加ant-design-vue无法渲染出页面
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构