splitPath.php
Table of Contents
Functions
- splitPath() : array<string|int, string>
- Splits a **canonical** filesystem path into two parts: 1. **Root** : the protocol / drive / leading slash portion 2. **Remainder** : the sub‑path that follows
Functions
splitPath()
Splits a **canonical** filesystem path into two parts: 1. **Root** : the protocol / drive / leading slash portion 2. **Remainder** : the sub‑path that follows
splitPath(string $path) : array<string|int, string>
Supported patterns
Input example | Returned root | Returned remainder |
---|---|---|
/var/www/html |
/ |
var/www/html |
C:/Windows/System32 |
C:/ |
Windows/System32 |
C: |
C:/ |
(empty) |
file:///home/user/docs |
file:/// |
home/user/docs |
\\\\server\\share\\folder (UNC) |
// |
server/share/folder |
Note : The input path is assumed to be canonical (slashes normalisés à
/
, pas de segments.
ou..
). The function does not perform any filesystem checks.
Parameters
- $path : string
-
Canonical path (absolute or relative, UNIX or Windows, with optional URL‑style scheme).
Tags
Return values
array<string|int, string> —An array with [0] => root, [1] => remainder. Both strings can be empty.