douxun4924 2016-10-10 05:51
浏览 50
已采纳

如何在php中从多维数组中打印数组特定值

Below is my array which i have printed:-

I want only the product_image from the array in loop

 Array
(
    [0] => Array
        (
            [product_option_id] => 247
            [product_id] => 66
            [product_option_value] => Array
                (
                    [0] => Array
                        (
                            [product_option_value_id] => 42
                            [color_product_id] => 54
                            [name] => Pink
                            [product_image] => catalog/demo/teddy/03.jpg
                            [image] => http://192.168.15.9/Kids_stores/image/cache/catalog/axalta-ral-3015-light-pink-polyester-30-matt-powder-coating-20kg-box--1447-p-50x50.jpg
                            [price] => 
                            [price_prefix] => +
                        )

                    [1] => Array
                        (
                            [product_option_value_id] => 41
                            [color_product_id] => 67
                            [name] => Light Brown
                            [product_image] => catalog/Teddies/12-Baby-teddy/05.jpg
                            [image] => http://192.168.15.9/Kids_stores/image/cache/catalog/option-color/light_brown-50x50.jpg
                            [price] => 
                            [price_prefix] => +
                        )

                    [2] => Array
                        (
                            [product_option_value_id] => 43
                            [color_product_id] => 68
                            [name] => Cream 
                            [product_image] => catalog/Teddies/12-Baby-teddy/11.jpg
                            [image] => http://192.168.15.9/Kids_stores/image/cache/catalog/option-color/cream-images-50x50.jpg
                            [price] => 
                            [price_prefix] => +
                        )

                )

            [option_id] => 5
            [name] => COLOR
            [type] => image
            [value] => 
            [required] => 0
        )

)
  • 写回答

8条回答 默认 最新

  • doufei8691 2016-10-10 05:56
    关注

    Solution for your edited input:-

    $image_array = array();
    
    foreach ($your_array as $arr){
       $image_array[] = array_column($arr['product_option_value'],'product_image');
    }
    

    Output:- https://eval.in/657966

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(7条)

报告相同问题?

悬赏问题

  • ¥15 商城生产日期批次库存问题
  • ¥15 esp8266控制共阳极wrgb灯板无法关闭所有led灯
  • ¥100 python读取速度问题
  • ¥15 stm32f407使用DMA问题
  • ¥15 您好 这个API接口该怎么弄 网站搭建好了 API也有 现在就不知道该怎么填写API 不知道怎么用
  • ¥88 用uniapp写一个多端的程序,用到高德地图,用高德的JSAPI吗?
  • ¥20 关于#c++#的问题:水果店管理系统
  • ¥30 dbLinq最新版linq sqlite
  • ¥20 对D盘进行分盘之前没有将visual studio2022卸载掉,现在该如何下载回来
  • ¥15 完成虚拟机环境配置,还有安装kettle