file_uri_target($uri)
Returns the part of a URI after the schema.
string $uri: A stream, referenced as "scheme://target" or "data:target".
string|bool A string containing the target (path), or FALSE if none. For example, the URI "public://sample/test.txt" would return "sample/test.txt".
function file_uri_target($uri) { // Remove the scheme from the URI and remove erroneous leading or trailing, // forward-slashes and backslashes. $target = trim(preg_replace('/^[\w\-]+:\/\/|^data:/', '', $uri), '\/'); // If nothing was replaced, the URI doesn't have a valid scheme. return $target !== $uri ? $target : FALSE; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!file.inc/function/file_uri_target/8.1.x