In PHP I have a string, for example: " http://localhost:8888/Web_api_bachelor/public/uploads/images/image1.png "
I want to split this string, so I get a new string that starts after the "uploads/" part in the original string. So the new string is "images/image1.png".
How do I achieve this in PHP?
$result = end(explode('uploads/', $string)); where $string is the input;
This is where strstr() comes in handy.
$string = "http://localhost:8888/Web_api_bachelor/public/uploads/images/image1.png";
echo strstr($string, "uploads");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.