看板 PHP 關於我們 聯絡資訊
我想抓取字串中 某個字之後 且 某個字之前 的字串 例如 1158/1794529955_c83awegba_o.jpg 我只要黃色的部份 由於其中數字的位數是會改變的 參考了手冊後想說用strstr來寫 寫出下面這樣的code $match = '2108/1797529955_c83a0ed7ba_s.jpg'; $imgid = strstr(strstr($match, '/'),'_',true); 但是卻回應參數錯誤 請問出了什麼問題了嗎? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.64.141.223 ※ 編輯: sinstar 來自: 61.64.141.223 (11/02 21:25)
kasase:strstr returns the portion of string 11/02 22:28
kasase:而且他只接受兩個參數 11/02 22:30
nahp:除了以上,也可以用正規表示來做唷 11/02 22:46
michaelz:preg_match('/\/(\d+)_/', $match, $result); 11/03 13:24