Limit characters in a string
Posted: Wed Jan 31, 2007 9:17 pm
Hi,
Im trying to create a function to limit the characters within a string, then keep going untill it finds the first space in the string and echo the results.
Thats what I have so far, but makes the browser output page can not be displayed.
Am I on the right track?
Thanks
Im trying to create a function to limit the characters within a string, then keep going untill it finds the first space in the string and echo the results.
Code: Select all
function LimitString() {
$limit=14;
$value = substr($value, $limit, 1);
if($value != " "){
while($value != " "){
$i = 1;
$limit = $limit + $i;
$value = substr($value, $limit, 1);
}
}
$value = substr($value, 0, $limit);
return $value;
}Am I on the right track?
Thanks