[ create a new paste ] login | about

Link: http://codepad.org/y5KN6rNl    [ raw code | output | fork ]

BluePanther - PHP, pasted on Aug 28:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
function recur_trim($string){ 
    $trim = array( '\n', '\r', ' ', '\t', '\0', '\x0B' ); 
    $string = trim($string); 
    if(in_array(substr($string, 0, 1), $trim) || in_array(substr($string, -1), $trim)){ 
        return recur_trim($string); 
    } 
    else{ 
        return $string; 
    } 
}  
var_dump("Test\n\n");
var_dump(trim("Test\n\n"));
var_dump( recur_trim("Test\n\n"));
?>


Output:
1
2
3
4
5
string(6) "Test

"
string(4) "Test"
string(4) "Test"


Create a new paste based on this one


Comments: