Anglais Francais Prosygma 

Italie
-
    hebergement 

asp
prosygma_logo



 Divers (1)  Chaînes (31)  Dates (18)  Nombres (8)  Structures (5) 
 Tableaux (6) 
asc/ord - chr - crunch - cstr/(string) - dosql/addslashes - ereg_replace - htmlspecialchars - instr/strpos - instrrev/strrpos - lcase/strtolower - left - len/strlen - ltrim - mid/substr - nl2br - notag - parcelstr - password - replace/str_replace - right - rtrim - space - string/str_repeat - tarea/htmlentities - trim - ucase/strtoupper - ucfirst - undosql/stripslashes - urldecode - urlencode - wrapstr
CRUNCH 
Coupe une chaîne à environ une longueur donnée sans couper les mots si possible...
ASP
<%
function crunch(tx,lg)
   tmp = 1
   if len(tx)>lg then tmp = instr(lg,tx," ")
   if tmp>1 then tx2 = mid(tx,1,tmp) _
   else tx2 = mid(tx,1,lg)
   if tx2<>tx then tx2 = tx2 & " ..."
   crunch = tx2
end function

response.write crunch(chaine,nombre)
%>

PHP
<?
function crunch($tx,$lg) {
   $tmp = 0;
   if(strlen($tx)>$lg) $tmp = strpos($tx," ",$lg);
   if($tmp) $tx2 = substr($tx,0,$tmp);
   else $tx2 = substr($tx,0,$lg);
   if($tx2!=$tx) $tx2.=" ...";
   return $tx2;
}

echo crunch($chaine,$longueur);
?>

JavaScript
<script>
function crunch(tx,lg) {
   tmp = (tx.length>lg) ? tx.indexOf(" ",lg) : 0
   tx2 = (tmp>0) ? tx.substr(0,tmp) : tx.substr(0,lg)
   if(tx2!=tx) tx2+=" ..."
   return tx2
}

document.write(crunch(chaine,longueur))
</script>

© ASP-PHP.net 11/01/2003