Quote Originariamente inviata da badaze Visualizza il messaggio
Forse non ho letto bene, ma penso si potrebbe rimpiazzare gran parte del codice di doHYPEN con

Codice PHP:
                $hyphen[0]=substr($string0$n+1);
                if (
$a != " ") { $hyphen[0] .="-";}                
                
$hyphen[1]=substr($string$n+1);                
                return 
$hyphen
prima vanno però verificate le condizioni e dopo se soddisfatte si tronca la parola
si potrebbe rifare il codice così:

Codice PHP:
function doHYPHEN($string$start){
    
$len=strlen($string);
    for(
$n=$start;$n<$len-1;$n++){
        
$a=strtolower($string{$n});
        
$b=strtolower($string{$n+1});
        
$c=strtolower($string{$n+2});
        if((!
isN($a) and !isN($b)) or $a!="s"){
            if(
$a==" "){//è uno spazio
                
$hyphen[0]=substr($string0$n+1);
                
$hyphen[1]=substr($string$n+1);
                return 
$hyphen;
            }
            if((
$a==$b and $n<$len-and $c!=" ") or (isV($a) and $b=="s") or (isL($a) and $b=="s") or (isV($a) and isC($b) and isV($c)) or (isV($a) and isC($b) and isL($c)) or (isL($a) and isC($b) and isV($c)) or (isL($a) and isC($b) and isL($c)) or (isV($a) and isL($b) and isV($c)) or (isL($a) and isL($b) and isV($c))){
                
$hyphen[0]=substr($string0$n+1)."-";
                
$hyphen[1]=substr($string$n+1);
                return 
$hyphen;
            }
        }
    }
    
$hyphen[0]=$string;
    return 
$hyphen;

più che altro era per comodità di lettura del codice