夜间福利网站,免费动漫av,一级做a爰片久久毛片免费陪,夜夜骑首页,黄色毛片视频,插插插操操操,综合av色

php采集文章中的圖片獲取替換到本地實(shí)例

時(shí)間:2025-12-02 03:40:24 php語(yǔ)言

php采集文章中的圖片獲取替換到本地實(shí)例

  導(dǎo)語(yǔ):PHP中如何把圖片替換到本地中,你知道這樣的程序要怎么寫嗎?以下的是對(duì)php采集文章中的圖片獲取替換到本地的實(shí)現(xiàn)代碼進(jìn)行了詳細(xì)的分析介紹,有需要的朋友可以參考一下。

  代碼如下:

  /**

  * 獲取替換文章中的圖片路徑

  * @param string $xstr 內(nèi)容

  * @param string $keyword 創(chuàng)建照片的文件名

  * @param string $oriweb 網(wǎng)址

  * @return string

  *

  */

  function replaceimg($xstr,$keyword, $oriweb){

  /pic/p>

  $d = date('Ymd', time());

  $dirslsitss = '/var/www/weblist/uploads/'.$keyword.'/'.$d;/pic/p>

  if(!is_dir($dirslsitss)) {

  @mkdir($dirslsitss, 0777);

  }

  /pic/p>

  preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $xstr, $match);

  foreach($match[1] as $imgurl){

  $imgurl = $imgurl;

  if(is_int(strpos($imgurl, 'http'))){

  $arcurl = $imgurl;

  } else {

  $arcurl = $oriweb.$imgurl;

  }

  $img=file_get_contents($arcurl);

  if(!empty($img)) {

  /pic/p>

  $fileimgname = time()."-".rand(1000,9999).".jpg";

  $filecachs=$dirslsitss."/".$fileimgname;

  $fanhuistr = file_put_contents( $filecachs, $img );

  $saveimgfile = "/uploads/$keyword"."/".$d."/".$fileimgname;

  $xstr=str_replace($imgurl,$saveimgfile,$xstr);

  }

  }

  return $xstr;

  }

【php采集文章中的圖片獲取替換到本地實(shí)例】相關(guān)文章:

php中fsockopen用法實(shí)例11-07

php獲取新浪微博數(shù)據(jù)API的實(shí)例代碼02-18

php多個(gè)文件及圖片上傳實(shí)例詳解01-23

php中return的用法實(shí)例分析10-12

php中獲取數(shù)組長(zhǎng)度的方法12-01

php中實(shí)現(xiàn)回刪功能實(shí)例01-26

PHP中檢測(cè)ajax請(qǐng)求的代碼實(shí)例03-16

php畫圖實(shí)例09-15