wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



before_last_bar › WordPress Function

Od2.8.0
Przestarzałyn/a
before_last_bar ( $text )
Parametry:
  • (string) $text A pipe-delimited string.
    Wymagane: Tak
Powrót:
  • (string) Either $text or everything before the last pipe.
Zdefiniowane na:
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.


Źródło

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