惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
T
Threat Research - Cisco Blogs
小众软件
小众软件
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tailwind CSS Blog
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
博客园 - 【当耐特】
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
S
Secure Thoughts
O
OpenAI News
P
Proofpoint News Feed
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
T
Tenable Blog
A
Arctic Wolf
L
LINUX DO - 热门话题
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
博客园 - Franky
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
博客园_首页
雷峰网
雷峰网
IT之家
IT之家
PCI Perspectives
PCI Perspectives
L
LINUX DO - 最新话题
H
Heimdal Security Blog

博客园 - bluce chen

swif debounce实现 oculus quest2的思考 博文阅读密码验证 - 博客园 用户中心 - 博客园 https点对点转发响应示意图 Share架构的一些心得 flutter输入颜色枚举卡顿假死 n2n网络环境搭建 p2p技术之n2n源码核心简单分析一 分享一个14年写的用户管理类-swift版 MIUI通过xposed自动设置root权限 基于xposed实现android注册系统服务,解决跨进程共享数据问题 2017 UICollectionView swift2模版 angularjs 分页精华代码 Reveal分析IOS界面,plist文件读取 结合阿里云服务器,设置家中jetson tk1随时远程登陆 sqlite3 根据实体自动生成建表语句 prism4 StockTrader RI 项目分析一些体会2
php嵌套数组递归搜索返回数组key
bluce chen · 2015-02-06 · via 博客园 - bluce chen
var rewardTypes={"experience":{"\u7ecf\u9a8c\u503c":{"1":"\u660e\u661f\u6587\u827a\u996d","2":"\u6587\u827a","3":"\u963f\u91cc\u5df4\u5df4\u7f51"}},"money":{"\u865a\u62df\u8d27\u5e01":{"little_red_heart":"\u5c0f\u7ea2\u5fc3","golden_heart":"\u91d1\u8272\u4e4b\u5fc3","diamond_heart":"\u94bb\u77f3\u5fc3"}}};

使用1:

getShowText("3",rewardTypes,true);

返回:

"经验值"

使用2:

getShowText("3",rewardTypes);

返回:

"阿里巴巴网"

//递归搜索key对应文本,isParent=true则返回所在父节点对应文本名,false则返回匹配到的节点文本
function getShowText(keyid,data,isParent){
    var title=""; 
    for(var key in data){
        if(keyid==key){
            if(typeof(data[key])=="object"){
                for(var item in data[key]){
                    title=item;
                    break;
                }
                break;
            }else{
                title=data[key];
            }
            break;
        }else if(typeof(data[key])=="object"){ 
            title=getShowText(keyid,data[key],isParent);
            if(title!=""){
                if(isParent){
                    for(var item in data[key]){
                        title=item;
                    }
                }
                break;
            }
        }
    }
    return title;
}