Re: [請益] 將一個有行號的php檔去行號

看板PHP作者 (hsnugo)時間17年前 (2008/06/29 10:33), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串4/4 (看更多)
※ 引述《Geniusking (真理斯金)》之銘言: : ※ 引述《dinos (守護神)》之銘言: : : if(!empty($_FILES['UpFile']['name'])){ : : file_put_contents($upload_dir . $_FILES['UpFile']['name'], : : trim(preg_replace('/^1\./','', : : preg_replace('/[\r\n]+\s*\d+\./',"\n", : : file_get_contents($_FILES['UpFile']['tmp_name']) : : ) : : )) : : ); : : } : 謝謝大大的指點,我做了一點修改 : if(!empty($_FILES['UpFile']['name'])){ : file_put_contents($upload_dir . $_FILES['UpFile']['name'], : preg_replace('/\d*\.\s/','', : file_get_contents($_FILES['UpFile']['tmp_name'])) : ); : } 我想 如果字串中有符合regular expr的 也會被換掉喔 ex: echo "1. abc 2. abc 3333. abc"; 所以前面那位回答的大大才會把[\r\n]這種東西寫進去 不過那位大大的 /^1\./ 似乎也會match到字串中有的1.xxx的字串 這樣的regular expr不知道要怎麼寫才好>"< -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.90.106

06/29 11:47, , 1F
string file_get_contents ( string $filename, ...)
06/29 11:47, 1F

06/29 11:48, , 2F
/^ 的意思是從頭來
06/29 11:48, 2F
文章代碼(AID): #18PlI4aE (PHP)
文章代碼(AID): #18PlI4aE (PHP)