note 49700 deleted from function.substr by philip

From: Date: Sat, 23 May 2009 14:06:52 +0000
Subject: note 49700 deleted from function.substr by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155906@lists.php.net to get a copy of this message
Note Submitter: mancini at nextcode dot org ---- here are two functions to shrink a string to specified lenght , normally (stri...) or reversed (...ing) <?php //limit chars function limitch($value,$lenght){ if (strlen($value) >= $lenght ){ $limited = substr($value,0,$lenght); $limited .= "..."; } return $limited; } //limit chars reversed function limitchrev($value,$lenght){ if (strlen($value) >= $lenght ){ $start = strlen($value)- $lenght; $limited = "..."; $limited .= substr($value,$start,$lenght); } return $limited; } ?>

« previous php.notes (#155906) next »