Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Max. duljina riječi i razdvajanje

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
Zeus



Joined: 09 Sep 2003
Posts: 775
Location: Čakovec

PostPosted: 18.12.2008 12:01    Post subject: Max. duljina riječi i razdvajanje Add user to your forum ignore list Reply with quote

Dakle, imam textbox i htio bih limitirati broj slova u riječi na recimo 50 prilikom spremanja tog teksta koji se napise. Kako to najjednostavnije napraviti, da razdvoji tu rijec onda na 2 dijela (ili 3 i više). Radi se o PHP-u.
Back to top
View user's profile Send private message Twitter profile
sphx



Joined: 02 Jun 2004
Posts: 109
Location: Split

PostPosted: 18.12.2008 14:33    Post subject: Add user to your forum ignore list Reply with quote

sličan problem sam rješavao na način da nakon svakog slijeda od 30 uzastopnih znakova bez razmaka (dakle sigurno netko kucka znakove a ne piše riječi) dodam jedan razmak

drugi način je staviti overflow:hidden, pa ako se netko i igra, neće pucati web
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ghosap



Joined: 18 Sep 2003
Posts: 79

PostPosted: 18.12.2008 14:57    Post subject: Add user to your forum ignore list Reply with quote

1) php funkcija wordwrap
2) nesto tipa ovog, $str je ulazni i izlazni string
Code:

function my_chunk($str){return chunk_split($str, 50, ' ');}
$str = array_map( 'my_chunk', explode(' ', $str) );

P.S. ovo je iz glave, pa moguce da ima neki propust

Last edited by ghosap on 18.12.2008 15:00; edited 1 time in total

_________________
. . . and when the balance is lost all that is left is the reckening . . .
Back to top
View user's profile Send private message
ghosap



Joined: 18 Sep 2003
Posts: 79

PostPosted: 18.12.2008 14:58    Post subject: Add user to your forum ignore list Reply with quote

my_chunk uzma string i lomi ga na 50 znakova i između stavlja razmak
a ovo array_map radi taj my_chunk za svaki element explodea a explode razlomi array na razmake tj rijeci, naravno predpostavka je da nemas interpunkcija, al ovo ti bi generalno trebalo dati ideju

_________________
. . . and when the balance is lost all that is left is the reckening . . .
Back to top
View user's profile Send private message
Zeus



Joined: 09 Sep 2003
Posts: 775
Location: Čakovec

PostPosted: 18.12.2008 15:22    Post subject: Add user to your forum ignore list Reply with quote

Ok, fala obadvojici Smile
Back to top
View user's profile Send private message Twitter profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group