Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 12 su 12

Discussione: url troppo lunghi...

  1. #11
    così dovrebbe andare

    $testo = preg_replace("/\[LINK\](.*?)\[\/LINK\]/i", "\";echo \"\".substr(\"$1\", 0, 20).\"...\".substr(\"$1\", strlen(\"$1\")-5, 5).\"\"; echo \"", $testo);
    eval("echo \"".$testo."\";");
    anija . è solo un blog
    www.anija.it

    «i'm a fountain of blood · in the shape of a girl»

  2. #12
    codice:
    function urlLength( $url, $length ) {
    	$st = '<a href="'.$url.'">';
    	if( ( $a = strlen( $url ) ) > $length ) {
    	        $b = floor( $length / 2 );
    		$url = substr( $url, 0, $b )."...".substr( $url, -( $b - 3 ) );
    	}
    	return $st.$url.'</a>';
    }
    
    $urlMaxLength = 20;
    $st = "askdaidm [LINK]http://www.asd.it/dwadwadwadwadadwadwadw[/LINK] asdasd";
    echo preg_replace( "/(?i)\[link\]([^\a]+?)\[\/link\]/e", "urlLength( \"\\1\", {$urlMaxLength} )", $st );


    P.S. eval puo' essere usato direttamente nella preg aggiungendo e in fondo
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.