• 三维数组循环里面的二维数组,加参数循环的方法


    $list_new是三维数组,里面根据size_id,增加不同的长度和宽度尺寸
    Array
    (
        [1709115930244442] => Array
            (
                [0] => Array
                    (
                        [id] => 119
                        [type] => 1
                        [prompt] => Design a pair of earrings
                        [category_id] => 
                        [style_id] => 
                        [upload_image] => 
                        [image] => https://image.jewelryhunt.net/zhaowu/20240229/cf3c0764b8da63d25b89b17ea79021dd.png
                        [image_id] => 1709166990030453
                        [image_id_pid] => 1709115930244442
                        [size_id] => 
                        [createtime] => 1709166990
                    )
    
                [1] => Array
                    (
                        [id] => 118
                        [type] => 1
                        [prompt] => Design a pair of earrings
                        [category_id] => 
                        [style_id] => 
                        [upload_image] => 
                        [image] => https://image.jewelryhunt.net/zhaowu/20240229/51e89aae7c70d153fe58bcb6a3b17bc5.png
                        [image_id] => 1709166936353149
                        [image_id_pid] => 1709115930244442
                        [size_id] => 
                        [createtime] => 1709166936
                    )
    
            )
    
        [1709101780997618] => Array
            (
                [2] => Array
                    (
                        [id] => 92
                        [type] => 1
                        [prompt] => Design a necklace
                        [category_id] => 
                        [style_id] => 
                        [upload_image] => 
                        [image] => https://image.jewelryhunt.net/zhaowu/20240228/8dd8d95230c5bd0cb1711f460460f9cd.png
                        [image_id] => 1709108628735260
                        [image_id_pid] => 1709101780997618
                        [size_id] => 
                        [createtime] => 1709108628
                    )
    
            )
    
        [1709078780835198] => Array
            (
                [3] => Array
                    (
                        [id] => 41
                        [type] => 1
                        [prompt] => Design a 90s inspired ring.
                        [category_id] => 
                        [style_id] => 
                        [upload_image] => 
                        [image] => https://image.jewelryhunt.net/zhaowu/20240228/a458f33de011504fe1cf0a3062593326.png
                        [image_id] => 1709082181235856
                        [image_id_pid] => 1709078780835198
                        [size_id] => 
                        [createtime] => 1709082181
                    )
    
                [4] => Array
                    (
                        [id] => 39
                        [type] => 1
                        [prompt] => Design a 90s inspired ring.
                        [category_id] => 
                        [style_id] => 
                        [upload_image] => 
                        [image] => https://image.jewelryhunt.net/zhaowu/20240228/1c89e90ea6e69fb1f17b28a618cf7ff3.png
                        [image_id] => 1709081737985906
                        [image_id_pid] => 1709078780835198
                        [size_id] => 
                        [createtime] => 1709081738
                    )
    
            )
    
    )
    
    if ($list_new){
        foreach ($list_new as $k=>$val){
                foreach ($val as $kk=>$v) {
    
                    if ($v['size_id'] == 1) {
                        $list_new[$k][$kk]['size_name'] = '1024 X 1024px';//1:1
                        $list_new[$k][$kk]['width'] = 512;
                        $list_new[$k][$kk]['height'] = 512;
    
                    } else if ($v['size_id'] == 2) {
                        $list_new[$k][$kk]['size_name'] = '768 X 1024px';//3:4
                        $list_new[$k][$kk]['width'] = 384;
                        $list_new[$k][$kk]['height'] = 512;
    
                    } else if ($v['size_id'] == 3) {
                        $list_new[$k][$kk]['size_name'] = '768 X 1360px';//9:16
                        $list_new[$k][$kk]['width'] = 384;
                        $list_new[$k][$kk]['height'] = 680;
    
                    } else if ($v['size_id'] == 4) {
                        $list_new[$k][$kk]['size_name'] = '1024 X 768px';//4:3
                        $list_new[$k][$kk]['width'] = 512;
                        $list_new[$k][$kk]['height'] = 384;
    
                    } else {
                        $list_new[$k][$kk]['size_name'] = '1360 X 768px';//16:9
                        $list_new[$k][$kk]['width'] = 680;
                        $list_new[$k][$kk]['height'] = 384;
                    }
                    $list_new[$k][$kk]['createtime'] = date('F d, Y H:i', $v['createtime']);//转换这种格式May 22,2023  11:28
                }
        }
  • 相关阅读:
    tomcat线程池-深度分析tomcat线程池设计与现实
    【飞桨PaddleSpeech语音技术课程】— 一句话语音合成全流程实践
    树莓派4B(Pi buster)一键安装apt存在问题,WARNING: apt does not have a stable CLI interface
    关于mysql/mariadb会产生大量错误日志导致硬盘空间很快被占用问题的解决方法
    3种方法设置PPT文件保护
    【同名cookie引发的血案】多个站点平台采用同名cookie引起用户信息被覆盖
    Java并发编程学习5-对象的组合
    pytest文档82 - 用例收集钩子 pytest_collect_file 的使用
    一篇文章讲清楚芯片设计全流程及相关岗位划分
    Docker入门
  • 原文地址:https://blog.csdn.net/ahjxhy2010/article/details/136363993