before_last_bar()
Removes 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.
No Hooks.
Return
String
. Either $text or everything before the last pipe.
Usage
before_last_bar( $text );
- $text(string) (required)
- A pipe-delimited string.
Changelog
Since 2.8.0 | Introduced. |
before_last_bar() before last bar code WP 6.7.2
function before_last_bar( $text ) { $last_bar = strrpos( $text, '|' ); if ( false === $last_bar ) { return $text; } else { return substr( $text, 0, $last_bar ); } }