Wuu Posted April 17, 2009 Report Share Posted April 17, 2009 /*teksta samazināšana */ function crop ($text) { if (strlen($text) > 600) { $text = substr($text,0,600); $text = trim($text); $text = explode(" ", $text, -1); $text = implode(" ",$text); $text .='...'; } return $text; } Viss strādā ,bet nepatīk tā pēdējā fīča $text = explode(" ", $text, -1); //dzēšam pēdējo vārdu $text = implode(" ",$text); // Saliekam atpakaļ :) Google meklēju bet neko jēdzīgu neatradu ,tāpēc uzrakstīju pac. Bet man liekas kaut kā palēni es to fīču ar pēdējā vārda noņemšanu uzrakstīju ,ieteikumi? Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted April 17, 2009 Report Share Posted April 17, 2009 Es taisītu kaut kā tā. function crop ($text) { if (strlen($text) > 600) { $text = trim(substr($text,0,600)); $pos = strrpos($text,' '); $text = substr($text,0,$pos).'...'; } return $text; } Quote Link to comment Share on other sites More sharing options...
codez Posted April 17, 2009 Report Share Posted April 17, 2009 var uzreis strrpos norādīt 600 offsetu function crop ($text) { if (strlen($text) > 600) { $text = trim($text); $pos = strrpos($text,' ',600); $text = substr($text,0,$pos).'...'; } return $text; } Quote Link to comment Share on other sites More sharing options...
Wuu Posted April 17, 2009 Author Report Share Posted April 17, 2009 (edited) Paldies patestēsim ,vel ir problēma kā dabūt ārā parametrus no bbcoda piemēram man ir [imgl]http://lol.lv/xxx.png[/imgl] Kā lai dabon ārā http://lol.lv/xxx.png Edited April 17, 2009 by Wuu Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted April 17, 2009 Report Share Posted April 17, 2009 Ar bbcode_parse() varbūt. Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted April 17, 2009 Report Share Posted April 17, 2009 /\[imgl\](.*?)\[\/imgl\]/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.