看板 PHP 關於我們 聯絡資訊
※ 引述《sinstar (sinstar)》之銘言: : 我想抓取字串中 某個字之後 且 某個字之前 的字串 : 例如 1158/1794529955_c83awegba_o.jpg : 我只要黃色的部份 : 由於其中數字的位數是會改變的 : 參考了手冊後想說用strstr來寫 : 寫出下面這樣的code : $match = '2108/1797529955_c83a0ed7ba_s.jpg'; : $imgid = strstr(strstr($match, '/'),'_',true); ^^^^^多一個參數 還有你這樣$imgid會是_c83a0ed7ba_s.jpg 我想到的方法是 $tempary = explode('_', substr(strstr($match, '/'), 1)); $imgid = $tempary[0]; : 但是卻回應參數錯誤 : 請問出了什麼問題了嗎? : 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.30.32 ※ 編輯: kasase 來自: 140.112.30.32 (11/02 22:41)
sinstar:這樣似乎也不錯耶 可以問一下explode和strtok有什麼差別嗎 11/02 23:08