note 92473 modified in function.substr by danbrown
| From: | danbrown@php.net | Date: | Sun, 26 Jul 2009 15:43:38 +0000 |
| Subject: | note 92473 modified in function.substr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158742@lists.php.net to get a copy of this message | ||
Shortens the filename and its expansion has seen.
<?php
$file = "Hellothisfilehasmorethan30charactersandthisfayl.exe";
function funclongwords($file)
{
if (strlen($file) > 30)
{
$vartypesf = strrchr($file,".");
$vartypesf_len = strlen($vartypesf);
$word_l_w = substr($file,0,15);
$word_r_w = substr($file,-15);
$word_r_a = substr($word_r_w,0,-$vartypesf_len);
return $word_l_w."...".$word_r_a.$vartypesf;
}
else
return $file;
}
// RETURN: Hellothisfileha...andthisfayl.exe
?>
--was--
Shortens the filename and its expansion has seen.
[php]
$file = "Hellothisfilehasmorethan30charactersandthisfayl.exe";
function funclongwords($file)
{
if (strlen($file) > 30)
{
$vartypesf = strrchr($file,".");
$vartypesf_len = strlen($vartypesf);
$word_l_w = substr($file,0,15);
$word_r_w = substr($file,-15);
$word_r_a = substr($word_r_w,0,-$vartypesf_len);
return $word_l_w."...".$word_r_a.$vartypesf;
}
else
return $file;
}
[/php]
// RETURN: Hellothisfileha...andthisfayl.exe
// other simples on rollyz.net
http://php.net/manual/en/function.substr.php