Definition:
function wp_html_excerpt( $str, $count ) {}
Safely extracts not more than the first $count characters from html string.
UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* be counted as one character. For example & will be counted as 4, < as 3, etc.
Parameters
- integer $str: String to get the excerpt from.
- integer $count: Maximum number of characters to take.
Return values
returns:The excerpt.
Source code
function wp_html_excerpt( $str, $count ) { $str = wp_strip_all_tags( $str, true ); $str = mb_substr( $str, 0, $count ); // remove part of an entity at the end $str = preg_replace( '/&[^;\s]{0,6}$/', '', $str ); return $str; }
3767
No comments yet... Be the first to leave a reply!