pods_trim

Filter input and return sanitized output.

Description

(array|object|string) pods_trim( (mixed) $input, (constant) $charlist = null, (null) $lr = null ); 

Returns (array|object|string)

Parameters (3)

0. $input (mixed)
The string, array, or object to sanitize
1. $charlist — Optional. (constant) => null
List of characters to be stripped from the input.
2. $lr — Optional. (null) => null
Direction of the trim, can either be l or r..

Usage

  1. if ( !function_exists( 'pods_trim' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'pods-custom-content-types-and-fields/includes/data.php'; 
  3.  
  4. // The string, array, or object to sanitize 
  5. $input = null; 
  6.  
  7. // (optional) List of characters to be stripped from the input. 
  8. $charlist = null; 
  9.  
  10. // Direction of the trim, can either be 'l' or 'r'. 
  11. $lr = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = pods_trim($input, $charlist, $lr); 
  15.  

Defined (1)

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

/includes/data.php  
  1. function pods_trim ( $input, $charlist = null, $lr = null ) { 
  2.  
  3. $output = array(); 
  4.  
  5. if ( is_object( $input ) ) { 
  6. $input = get_object_vars( $input ); 
  7.  
  8. foreach ( $input as $key => $val ) { 
  9. $output[ pods_sanitize( $key ) ] = pods_trim( $val, $charlist, $lr ); 
  10.  
  11. $output = (object) $output; 
  12. elseif ( is_array( $input ) ) { 
  13. foreach ( $input as $key => $val ) { 
  14. $output[ pods_sanitize( $key ) ] = pods_trim( $val, $charlist, $lr ); 
  15. else { 
  16. if ( 'l' == $lr ) { 
  17. $output = ltrim( $input, $charlist ); 
  18. elseif ( 'r' == $lr ) { 
  19. $output = rtrim( $input, $charlist ); 
  20. else { 
  21. $output = trim( $input, $charlist ); 
  22.  
  23. return $output; 
  24.