File::stripLeadingSeparators()

File::stripLeadingSeparators() – strip leading separators from a path

Synopsis

require_once 'File.php';

string File::stripLeadingSeparators ( string $path , string $separator = DIRECTORY_SEPARATOR )

Description

This method removes the leading directory separator (like "/" on *nix) from a path name.

Parameter

  • string $path - the path name where the leading separator should be removed from.

  • string $separator - optional string that defines the separator. This parameter defaults to the value of the constant DIRECTORY_SEPARATOR that is pre-defined by PHP.

Return value

This methods returns the given path name without a leading directory separator.

Note

This function can be called statically.

Example

Using File::stripLeadingSeparators()

<?php
require_once "File.php";

echo 
File::stripLeadingSeparators("/home/foo/lala/");
?>

This example will print home/foo/lala/.

strips the root directory from a given path (Previous) strips trailing separators from a path (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.