I use PHP strpos()to find the needle in a paragraph of text. I struggle with finding the next word after the needle is found.
For example, consider the following paragraph.
$description = "Hello, this is a test paragraph. The SCREENSHOT mysite.com/screenshot.jpg and the LINK mysite.com/link.html is what I want to return.";
I can use strpos($description, "SCREENSHOT")to determine if SCREENSHOT exists, but I want to get the link after SCREENSHOT, namely mysite.com/screenshot.jpg. Similarly, I want to determine if the description contains LINK, and then returns mysite.com/link.html.
How can I use strpos()and then return the next word? I guess this can be done with RegEx, but I'm not sure. The next word will be “space after the needle, followed by something, and then space”.
Thank!
source
share