extractCanonicalParts.php
Table of Contents
Functions
- extractCanonicalParts() : array<string|int, string>
- Extracts the canonical path segments of « $pathWithoutRoot ».
Functions
extractCanonicalParts()
Extracts the canonical path segments of « $pathWithoutRoot ».
extractCanonicalParts(string $root, string $pathWithoutRoot) : array<string|int, string>
This method breaks down the input path into segments, and processes them to remove:
- Redundant current directory references (
.
) - Properly resolvable parent references (
..
)
It does not access the filesystem and works purely on string logic.
Parameters
- $root : string
-
The base root path. Used to determine whether
..
segments can be collapsed. If empty, leading..
segments will be preserved. - $pathWithoutRoot : string
-
The input path (already stripped of the root part).
Tags
Return values
array<string|int, string> —An array of canonical path segments.