Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

PHP rtrim — Strip whitespace (or other characters) from the end of a string

<?php

$text = "		These are a few words :) ...  ";
$binary = "x09Example stringx0A";
$hello  = "Hello World";
var_dump($text, $binary, $hello);

print "
";

$trimmed = rtrim($text);
var_dump($trimmed);

$trimmed = rtrim($text, " 	.");
var_dump($trimmed);

$trimmed = rtrim($hello, "Hdle");
var_dump($trimmed);

// trim the ASCII control characters at the end of $binary
// (from 0 to 31 inclusive)
$clean = rtrim($binary, "x00..x1F");
var_dump($clean);

?>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #PHP #rtrim #Strip #whitespace #string
ADD COMMENT
Topic
Name
3+4 =