wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



before_last_bar › WordPress Function

Seit2.8.0
Veraltetn/v
before_last_bar ( $text )
Parameter:
  • (string) $text A pipe-delimited string.
    Erforderlich: Ja
Gibt zurück:
  • (string) Either $text or everything before the last pipe.
Definiert in:
Codex:

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.


Quellcode

function before_last_bar( $text ) {
	$last_bar = strrpos( $text, '|' );
	if ( false === $last_bar ) {
		return $text;
	} else {
		return substr( $text, 0, $last_bar );
	}
}