before_last_bar() – Remove last item on a pipe-delimited string.

You appear to be a bot. Output may be restricted

Description

Remove last item on a pipe-delimited string.

Meant for removing the last item in a string, such as 'Role name|User role'. The original string will be returned if no pipe '|' characters are found in the string.

Usage

$string = before_last_bar( $string );

Parameters

$string
( string ) required – A pipe-delimited string.

Returns

string Either $string or everything before the last pipe.

Source

File name: wordpress/wp-includes/l10n.php
Lines:

1 to 8 of 8
function before_last_bar( $string ) {
  $last_bar = strrpos( $string, '|' );
  if ( false === $last_bar ) {
    return $string;
  } else {
    return substr( $string, 0, $last_bar );
  }
}
 

 View on GitHub View on Trac