How to use regex in PHP to get int after slash in string -
I tried to make a code in PHP which gets the subject id after a forward slash in a given string. Although the problem is that its return is nothing, how can I return it?
echo preg_match ('/ ([^ /] +' / ',' english / 478 ', $ discussion_id); sampling $ discussion_id; This is for an online forum, thanks for your help; It is highly appreciated if you need more information, please do not hesitate to leave a comment.
preg_match ("# / (\ d +) $ #", 'learn-english / 478', $ discussion_id); This will work for you.
ID (match number) to print; Need to resonate $ discussion_id [1] . This is a job.
For the new string, you will not need String expiration match ( $ ). Thus, regex will be: preg_match ("# / (\ d +) #", 'pen-palms to explore / 1161 & amp; t = visual debate, $ discussion_id); Sampling $ discussion_id [1];
Comments
Post a Comment