It is necessary for a well-known link to get the absolute path to the file on the server. I implement it as follows:
$image = preg_replace("/^http.*/{2}[^/]*/i", $_SERVER[DOCUMENT_ROOT], "http://example.com/image.jpg");
When executing this code, $image
takes the value null
, although in theory there should be a full path to the file. preg_last_error
says that no errors have occurred. I do not even know what could be wrong in one line of code ...
//
from the end of the line, and [^ \ /] * captures everything to image.jpg - ReinRaus