PHP/String/strrev
Содержание
Reversing a string by byte
<source lang="html4strict">
<?php
print strrev("This is not a palindrome.");
?>
</source>
Reversing Strings
<source lang="html4strict">
<?php
$astring = "Hello World"; echo strrev ($astring);
?>
</source>
Reversing Strings: string strrev ( string string )
<source lang="html4strict">
<?php $astring = "Hello World"; echo strrev ($astring); ?>
</source>
Truncating Text on Word Boundaries
<source lang="html4strict">
<?php function truncate_text_nicely($string, $max, $moretext) {
if (strlen($string) > $max) { $max -= strlen($moretext); $string = strrev(strstr(strrev(substr($string, 0, $max)), " ")); $string .= $moretext; } return $string;
} $str = "This is a test.This is a test.This is a test.This is a test.This is a test.This is a test."; $values = truncate_text_nicely($str, 20, "...");
echo "{$values}";
?>
</source>