如何删除扩展名.jpg后的文本抓取-php


How remove text after extension .jpg scraping - php

我有这个url要报废:example.com/upload/produse/epilatoare/SE810%20Face.jpg?最大宽度=800&最大高度=800我想删除.jpg之后的所有字符,我不知道怎么做。

抓取网站的代码是:

if(isset($this->request->post['image_scrapper'])){
                $imageQuery = $xpath->query("//div[@id='fancybox-content']//img/@src");
                if($imageQuery->length > 0){
                    foreach ($imageQuery as $key => $image){
                        $extensie = end((explode('/', $image->nodeValue)));
                        $extensie = end((explode('.', $extensie)));
                        $model = preg_replace("/[^a-zA-Z0-9 -'/]+/","",trim($this->request->post['model']));
                        $imageName = str_replace(" ","-",trim($this->request->post['product_description']['1']['name']));
                        $imageName = preg_replace("/[^a-zA-Z0-9 -]+/","",$imageName);
                        $imageName .= "-".preg_replace("/[^a-zA-Z0-9 -]+/","",$model);
                        $imageName = strtolower($imageName);
                        $imageName = preg_replace("/[-]+/","-",$imageName);
                        $imageName .= '-'.rand().'.'.$extensie;
                        $imageName = 'data/'.$imageName;
                        copy($image->nodeValue, DIR_IMAGE.$imageName);
                        if($key == '0'){
                            $this->model_catalog_product->firstImage($product_id, $imageName);
                        }else{
                            $this->model_catalog_product->aditionaleImage($product_id, $imageName);
                        }
                    }
                }else{
                    if(isset($this->session->data['error'])){
                        $this->session->data['error'] .= ' Produsul nu are imagini';
                    }else{
                        $this->session->data['error'] = 'Scrapper: Produsul nu are imagini.';
                    }
                }
            }

请帮帮我,感谢

试试这个:

$yourImage = substr($yourImage, 0, strpos($yourImage','.jpg'));