如何根据键值输出数组数据 [英] How to output array data based on key value

查看:148
本文介绍了如何根据键值输出数组数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



解析JSON后我有这个数组,如果类别是附件,如何得到数组项目的标题

Hi ,
I have this array after parsing the JSON , How to get the title of array item only if category is Accessories

(
    [0] => Array
        (
            [name] => Souq
            [title] => Upto 70% Off
            [category] => Accessories
        )

    [1] => Array
        (
            [name] => Beardo.
            [title] => 65% OFF 
            [category] => Personal Care
        )

    [2] => Array
        (
            [name] => Fnp
            [title] => Rs.100 off
            [category] => Gifts & Flowers
        )
     [3] => Array
        (
            [name] => Dreamz
            [title] => Rs.50 off
            [category] => Accessories
        )
)





所需产量:

Souq

Dreamz



< b>我尝试了什么:



我不知道用哪个函数来获得所需的结果,我已经解析了JSON并获得了这些数据但我需要对数据进行分类。



Desired Output :
Souq
Dreamz

What I have tried:

I am not getting idea which function to use to get desired result , I have parsed the JSON and got this data but I need to categorise the data .

推荐答案

首先。按条件过滤数组,这将返回索引0和3中的项目

First. Filter the array by condition, this will return the item in index 0 and 3


filterArr = array_filter(
filterArr = array_filter(


产品,功能(


这篇关于如何根据键值输出数组数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆