PHP/String/String Length
Finding the Length of a String with strlen()
<source lang="html4strict">
<? $membership = "asdfadsf"; if ( strlen( $membership ) == 4 )
print "Thank you!";
else
print "Your membership number must have 4 digits"; ?> </source>
Limit string length and display "..."
<source lang="html4strict">
<?php
// Limit $summary to how many characters? $limit = 100;
$summary = <<< summary Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text summary;
if (strlen($summary) > $limit) $summary = substr($summary, 0, strrpos(substr($summary, 0, $limit), " ")) . "..."; echo $summary;
?>