Re: [請益] 抓取字串中 特定字元前後字串 的問題

看板PHP作者 (土豆)時間16年前 (2007/11/03 14:17), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串6/6 (看更多)
※ 引述《sinstar (sinstar)》之銘言: : 我想抓取字串中 某個字之後 且 某個字之前 的字串 : 例如 1158/1794529955_c83awegba_o.jpg : 我只要黃色的部份 : 由於其中數字的位數是會改變的 : 參考了手冊後想說用strstr來寫 : 寫出下面這樣的code : $match = '2108/1797529955_c83a0ed7ba_s.jpg'; : $imgid = strstr(strstr($match, '/'),'_',true); : 但是卻回應參數錯誤 : 請問出了什麼問題了嗎? : 謝謝 可以用兩個split()來把前後切掉就好啦~ $str = '1158/1794529955_c83awegba_o.jpg'; list(, $tmp) = split('/', $str, 2); list($imgid, ) = split('_', $tmp); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.13.240.33 ※ 編輯: toodoo 來自: 163.13.240.33 (11/03 14:18)

11/04 23:00, , 1F
謝謝大家的指教 學到很多方法
11/04 23:00, 1F
文章代碼(AID): #17B1A4eR (PHP)
討論串 (同標題文章)
文章代碼(AID): #17B1A4eR (PHP)