bb_trim_for_db

The BuddyPress bb trim for db function.

Description

bb_trim_for_db( $string, $length ); 

Parameters (2)

0. $string
The string.
1. $length
The length.

Usage

  1. if ( !function_exists( 'bb_trim_for_db' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-formatting.php'; 
  3.  
  4. // The string. 
  5. $string = null; 
  6.  
  7. // The length. 
  8. $length = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bb_trim_for_db($string, $length); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-includes/functions.bb-formatting.php  
  1. function bb_trim_for_db( $string, $length ) { 
  2. $_string = $string; 
  3. if ( seems_utf8( $string ) ) { 
  4. $string = bb_utf8_cut( $string, $length ); 
  5. // if we have slashes at the end, make sure we have a reasonable number of them 
  6. if ( preg_match( '#[^\\\\](\\\\+)$#', $string, $matches ) ) { 
  7. $end = stripslashes($matches[1]); 
  8. $end = addslashes($end); 
  9. $string = trim( $string, '\\' ) . $end; 
  10. return apply_filters( 'bb_trim_for_db', $string, $_string, $length );