Jump to content
php.lv forumi

skripts, kas apgraiza tekstu


andrisp

Recommended Posts

kaadam nav aizkjeeries skriptinjs, kas paaraak garus vaardus sagriezh, bet linkus ieliek starp <a></a> un vizuaali saiisina bet nesagriezh - tipa http://www.example.com/asdasd/asdsad.php paraadiitos kaa www.example.com uz kuru var nospiest..

 

$txt = preg_replace("/.\S{20}/",'${0} ',$txt); ar shito es griezhu vaardus..

Edited by andrisp
Link to comment
Share on other sites

preg_replace("/((http|ftp)+(s)?:(\/\/)([\w]+(.[\w]+))([\w\-\.,@?^=%&:;\/~\+#]*[\w\-\@?^=%&:;\/~\+#])?)/i", "<a href=\"\\0\">[ saite ]</a>", $text);

atradu shitaadu, kas paarveido linkus, bet kaa lai uztaisa, lai vinjs starp <a></a> ieliktu , piemeeram, pirmos 15 simbolus no linka ?

Link to comment
Share on other sites

tā jau tev nav nekāda apgrizīšana, bet URL meklēšana tekstā...

 

function url_replacer( $arr )
{
  return '<a href="'.$arr[0].'">'.substr( $arr[0], 0, 15 ) . '...</a>';
}

$sp = '..tas_pats_kas_postā..';
$newText = preg_replace_callback( $sp, 'url_replacer', $text );

 

PS: kļūdas pielabo pats

Edited by Delfins
Link to comment
Share on other sites

×
×
  • Create New...