我有这个网址用于报废:example.com/upload/produse/epilatoare/SE810%20Face.jpg?maxwidth=800&maxheight=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.';
}
}
}
请帮帮我, 感谢
答案 0 :(得分:0)
试试这个:
$yourImage = substr($yourImage, 0, strpos($yourImage','.jpg'));