duancao1951 2016-03-18 02:51
浏览 69

将字符串分开并删除PHP中的某些键值对

I have a string that, when divided up by its only delimited ("="), comes out to be in the following form:

time0 -> 2016-03-18T01:33:52Z
time1 -> 2016-03-18T00:25:54Z
timezone0 -> GMT
timezone1 -> GMT
type0 -> Subscription
type1 -> General
email1 -> email@email.com
name0 -> first
name1 -> second
tr0 -> ###
tr1 -> ###
st0 -> Created
st1 -> Completed
amt1 -> 19.95
currency1 -> USD
fee1 -> -0.88
net1 -> 19.07

Here is the code for it ($result holds the full string):

foreach($result as $value){
    $value = explode("=", $value);
    print $value[0] . " -> " .$value[1] . "<br/>";
}

As you can see, there are 2 types of categories, one which is "Subscription" and one which is "General". What I am essentially looking to do is filter out for only a specific type. For example, if I am looking for type "Subscription", then the output should be as follows:

time0 -> 2016-03-18T01:33:52Z
timezone0 -> GMT
type0 -> Subscription
name0 -> first
tr0 -> ###
st0 -> Created

If there were multiple types with "subscription" (e.g. type0 and type2 were "Subscription"), then it would return the time0 and type2, timezone0 and timezone2, tr0 and tr2 etc.

Is this possible?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示