Returns a copy of a string, with all occurrences of ‘white space’ characters removed from the beginning and end of the string
Class: String
Parameters: $string – String to extend
d (Optional) – Integer specifying end trim selection
Syntax: $returnString=$trim($string [,d])
Returns:
• If d=0 or is not specified – The string that remains after all occurrences of ‘white space’ have been removed from both the beginning and end of $string
• If d=1 – The string that remains after all occurrences of ‘white space’ have been removed from the end of $string
• If d=2 – The string that remains after all occurrences of ‘white space’ have been removed from the beginning of $string
Remarks:
• Any space characters within the body of the string are not affected
Example:
//Example for the string $trim method
$s=” SEIKI BATCH SCRIPT ” //Set string
$result=”|” + $trim($s) + “|” //Result (= ‘|SEIKI BATCH SCRIPT|”)
message(“Default trimming of “ + $s + “ is “ + $result) //Display results message
$result=”|” + $trim($s, 2) + “|” //Result (= ‘|SEIKI BATCH SCRIPT |”)
message(“Lead trimming of “ + $s + “ is “ + $result) //Display results message
See Also: $pad