PHP發(fā)表文章時(shí)自動保存圖片實(shí)例代碼_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:php+mysql實(shí)現(xiàn)無限級分類無限級分類,主要是通過儲存上級分類的id以及分類路徑來實(shí)現(xiàn)。由于數(shù)據(jù)的結(jié)構(gòu)簡單,所以要將分類的關(guān)系由樹狀顯示,我只能想到用遞歸的方式給于實(shí)現(xiàn),下面是分類數(shù)據(jù)表結(jié)構(gòu)和自己寫的一個(gè)樹狀顯示函數(shù),有什么不妥的地方希望大家能指出。 表結(jié)構(gòu):id字段為分
- img_array = array();
- content1 = stripslashes(content1);
- if (get_magic_quotes_gpc()) content1 = stripslashes(content1);
- //echo content1;
- preg_match_all("/(src│SRC)="(http://(.+).(gif│jpg│jpeg│bmp│png))/isU",content1,img_array);
- img_array = array_unique(dhtmlspecialchars(img_array[2]));
- set_time_limit(0);
- foreach (img_array as key => value) {
- get_file = file_get_contents(value);
- filetime = time();
- filepath = "../uploadfile/".date("Y",filetime)."/".date("m",filetime)."/";
- !is_dir(filepath) ? mkdirs(filepath) : null;
- filename = date("YmdHis",filetime).random(1).'.'.substr(value,-3,3);
- fp = @fopen(filepath.filename,"w");
- @fwrite(fp,get_file);
- fclose(fp);
- content1 = preg_replace("/".addcslashes(value,"/")."/isU", "/uploadfile/".date("Y",filetime)."/".date("m",filetime)."/".filename, content1);
分享:PHP批量生成隨機(jī)用戶名生成6 ~ 16位的用戶名若干個(gè),主要是文本操作,同事前提是要有一個(gè)字符串包。主要包含三個(gè)程序。 程序一:負(fù)責(zé)從字典中隨機(jī)提取數(shù)據(jù),寫入一個(gè)新文件。(1.php) ?php /* 從字典文件中提取隨機(jī)值 */ file1 = ./Words.dic; file2 = ./common_pass_mini.dic
相關(guān)PHP教程:
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁面代碼執(zhí)行時(shí)間
- PHP中獎概率的抽獎算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運(yùn)算符優(yōu)先級介紹
- 關(guān)于PHP語言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國語言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說明:
PHP教程-PHP發(fā)表文章時(shí)自動保存圖片實(shí)例代碼
。