Skip to content

Instantly share code, notes, and snippets.

View iLiutaotao's full-sized avatar
🏠
Working from home

Liu Jiantao iLiutaotao

🏠
Working from home
View GitHub Profile
<?php
function DeleteHtml($str) //清除字符串的空格
{
$str = trim($str);
$str = preg_replace("/\t/","",$str);
$str = preg_replace("/\r\n/","",$str);
$str = preg_replace("/\r/","",$str);
$str = preg_replace("/\n/","",$str);
$str = preg_replace("/ /","",$str);
$str = preg_replace("/ /","",$str);
<?php
function saveImage($path) {
if(!preg_match('/\/([^\/]+\.[a-z]{3,4})$/i',$path,$matches)) //匹配图片
die('Use image please');
$image_name = strToLower($matches[1]);
$ch = curl_init ($path);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$img = curl_exec ($ch);
curl_close ($ch);