duanran6441 2016-11-06 23:01
浏览 108

在PHP中使用字符串键创建多维数组

This is kinda dumb question but after all these tries i get confused when i go too far...
I want a data like: Name Price Owner in different arrays as categories.
Like ie. i would like to access it via $product['category']['name']['name'] or $product['category']['name']['price'].
However i would need to check in which categories there is key ['name'] as well.
Any examples would be nice to learn from ;)

  • 写回答

1条回答 默认 最新

  • doulianglou0898 2016-11-06 23:10
    关注

    You can loop array:

    foreach($product['category'] as $cat) {
        if (isset($cat['name']) { //this is true if 'name' have value different than null
            continue; //cat have name
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大