wpseek.com
WordPress开发者和主题制作者的搜索引擎



before_last_bar › WordPress Function

Since2.8.0
已弃用n/a
before_last_bar ( $text )
参数:
  • (string) $text A pipe-delimited string.
    Required: Yes
返回:
  • (string) Either $text or everything before the last pipe.
定义在:
文档:

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.


源码

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