PHP發表文章時自動保存圖片實例代碼_PHP教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!

      推薦:php+mysql實現無限級分類
      無限級分類,主要是通過儲存上級分類的id以及分類路徑來實現。由于數據的結構簡單,所以要將分類的關系由樹狀顯示,我只能想到用遞歸的方式給于實現,下面是分類數據表結構和自己寫的一個樹狀顯示函數,有什么不妥的地方希望大家能指出。 表結構:id字段為分

      1. img_array = array(); 
      2. content1 = stripslashes(content1); 
      3. if (get_magic_quotes_gpc()) content1 = stripslashes(content1); 
      4. //echo content1; 
      5. preg_match_all("/(src│SRC)="(http://(.+).(gif│jpg│jpeg│bmp│png))/isU",content1,img_array); 
      6. img_array = array_unique(dhtmlspecialchars(img_array[2])); 
      7. set_time_limit(0); 
      8. foreach (img_array as key => value) { 
      9. get_file = file_get_contents(value); 
      10. filetime = time(); 
      11. filepath = "../uploadfile/".date("Y",filetime)."/".date("m",filetime)."/"
      12. !is_dir(filepath) ? mkdirs(filepath) : null; 
      13. filename = date("YmdHis",filetime).random(1).'.'.substr(value,-3,3); 
      14. fp = @fopen(filepath.filename,"w"); 
      15. @fwrite(fp,get_file); 
      16. fclose(fp); 
      17. content1 = preg_replace("/".addcslashes(value,"/")."/isU""/uploadfile/".date("Y",filetime)."/".date("m",filetime)."/".filename, content1); 

      分享:PHP批量生成隨機用戶名
      生成6 ~ 16位的用戶名若干個,主要是文本操作,同事前提是要有一個字符串包。主要包含三個程序。 程序一:負責從字典中隨機提取數據,寫入一個新文件。(1.php) ?php /* 從字典文件中提取隨機值 */ file1 = ./Words.dic; file2 = ./common_pass_mini.dic

      來源:模板無憂//所屬分類:PHP教程/更新時間:2012-06-17
      相關PHP教程