Re: [請益] 抓取字串中 特定字元前後字串 的問題
※ 引述《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)
推
11/02 23:08, , 1F
11/02 23:08, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 6 篇):