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 ;)
在PHP中使用字符串键创建多维数组
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
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 } }
解决 无用评论 打赏 举报