duanjuete9206 2015-08-21 07:44
浏览 30

PHP中的数组错误在PHP中迁移映像时

I got this error when I'm trying to migrate my image from Prestashop to Opencart using PHP. Can anyone here helps me? How can I fix the error?

It seems like the array have a problem. Any suggestions thanks.

 <?php
    class ControllerToolMigrate extends Controller {
        public function index() {
            $this->load->model('catalog/product');
            $filter_data = array(
                'start'=> 0,
                'limit'=> 5
            );     
            $results = $this->model_catalog_product->getProductsImage($filter_data);   
            foreach ($results as $result) {
                foreach($result as $sub_product){
                    $str = $sub_product['id_image'];
                    $arr1 = str_split($str);
                    $arr2 = str_split($str,2);
                    print_r($arr1);
                    print_r($arr2);       
                    $link = '';
                    echo $str;
                    foreach($arr1 as $id){
                        $com = array($id);      
                        $link .= $com[0] .'/';
                    }
                    $link .= $str; 
                    echo var_dump ($link);
                    echo $link;  
                    $newLink = 'http://localhost/onlinestore/img/p/'.$link.'-large_default.jpg';

                    //Get the file
                    $content = file_get_contents($newLink);
                    //Store in the filesystem.
                    $fp = fopen("../upload/image/catalog/demo/p/".$str."-large_default.jpg", "w");
                    fwrite($fp, $content);
                    fclose($fp);
                }       
            }
            //Get the file
            /*$content = file_get_contents("http://www.tImOLI12t.my/onlinestore/img/p/9/9-large_default.jpg");
            //Store in the filesystem.
            $fp = fopen("../upload/image/catalog/demo/p/large_default.jpg", "w");
            fwrite($fp, $content);
            fclose($fp);*/
        }
    }

Here's my error

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程