untrailingslashit

Removes trailing forward slashes and backslashes if they exist.

Description

(string) untrailingslashit( (string) $string ); 

The primary use of this is for paths and thus should be used for paths. It is not restricted to paths and offers no specific path support.

Returns (string)

String without the trailing slashes.

Parameters (1)

0. $string (string)
What to remove the trailing slashes from.

Usage

  1. if ( !function_exists( 'untrailingslashit' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // What to remove the trailing slashes from. 
  5. $string = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = untrailingslashit($string); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/formatting.php  
  1. function untrailingslashit( $string ) { 
  2. return rtrim( $string, '/\\' );