PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Jul 22, 2019 5:48 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Mon Aug 23, 2004 1:43 pm 
Offline
Forum Regular
User avatar

Joined: Thu Jan 08, 2004 12:22 pm
Posts: 926
Location: ecuador


Last edited by ol4pr0 on Sun Aug 29, 2004 11:28 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 2:14 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA
substr can be used.. unless you don't want to come into the middle of a word.. preg_replace can be used for extracing the words and stripping/ignoring tags and bbcode


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 4:29 pm 
Offline
Forum Regular
User avatar

Joined: Thu Jan 08, 2004 12:22 pm
Posts: 926
Location: ecuador
thx


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 4:09 pm 
Offline
Forum Regular
User avatar

Joined: Thu Jan 08, 2004 12:22 pm
Posts: 926
Location: ecuador
[quote=feyd]
substr can be used.. unless you don't want to come into the middle of a word
[quote]

I am prolly doing something wrong here. but i am still ending up in the middle of some word

Syntax: [ Download ] [ Hide ]
echo substr($string, 0,30);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 4:27 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA
something like this may work (untested)
Syntax: [ Download ] [ Hide ]
<?php



preg_match('#^\s*(.{26,}?)\s*.*$#', $test, $match);



?>
it should grab the last word, if it runs over.. not too sure though.


Last edited by feyd on Thu Aug 26, 2004 4:33 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 4:28 pm 
Offline
DevNet Resident
User avatar

Joined: Thu Feb 12, 2004 8:19 pm
Posts: 1165
Location: ohio
i wonder whats wrong with his substr? it looks good to me.

can u echo out the $string and get the text u wish to play with?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 4:33 pm 
Offline
Forum Regular
User avatar

Joined: Thu Jan 08, 2004 12:22 pm
Posts: 926
Location: ecuador


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 4:39 pm 
Offline
DevNet Resident
User avatar

Joined: Thu Feb 12, 2004 8:19 pm
Posts: 1165
Location: ohio


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 4:39 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 4:52 pm 
Offline
Forum Regular
User avatar

Joined: Thu Jan 08, 2004 12:22 pm
Posts: 926
Location: ecuador


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 5:08 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 29, 2004 11:09 am 
Offline
Forum Regular
User avatar

Joined: Thu Jan 08, 2004 12:22 pm
Posts: 926
Location: ecuador


Last edited by ol4pr0 on Sun Aug 29, 2004 11:15 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 29, 2004 11:15 am 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA
you may want to add the 's' modifier into the regex:
Syntax: [ Download ] [ Hide ]
//.........

preg_match('#^\s*(.{60,}?)\s+.*$#s', ...........


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 29, 2004 11:19 am 
Offline
Forum Regular
User avatar

Joined: Thu Jan 08, 2004 12:22 pm
Posts: 926
Location: ecuador
that s would stand for space ? i asume


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 29, 2004 11:26 am 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA
http://www.php.net/manual/en/reference. ... ifiers.php


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: Exabot [Bot] and 5 guests


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 post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group