Un motore di ricerca WordPress per sviluppatori e autori di temi



before_last_bar ›

Da2.8.0
Deprecaton/a
before_last_bar ( $string )
Parametri:
  • (string) $string A pipe-delimited string.
    Richiesto:
Ritorna:
  • (string) Either $string or everything before the last pipe.
Definito a:
Codex:

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.



Sorgenti

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