I have text string like :
[CLOSED][#SD_1623834126_001] lorem ipsum ?
and question is, how I get unique code/my ticket number #SD_xxxx ?
Please help me guys, thanks..
Advertisement
Answer
You could use preg_match_all
with the regex pattern #w+
to capture all hashtag matches in your input:
$input = "[CLOSED][#SD_1623834126_001] lorem ipsum ?"; preg_match_all("/#w+/", $input, $matches); print_r($matches[0][0]); // #SD_1623834126_001