Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PHP extracting text from between two seperate points

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
Diagmato
LXF regular


Joined: Sat Apr 01, 2006 10:37 pm
Posts: 272
Location: Cardiff

PostPosted: Tue Dec 05, 2006 10:32 pm    Post subject: PHP extracting text from between two seperate points Reply with quote

Im trying to write code which:

-finds the first occurance of ... ("..." is a sentance).
-Somehow takes the sentance from between the bbcode, and stores it in another variable

I was initially thinking of explode(), however the start and ending 'tokens' are different.

Any ideas?
_________________
My Blog

Micro$oft gives you Windows, Linux gives you the full house
Back to top
View user's profile Send private message MSN Messenger
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8456
Location: Warrington, UK

PostPosted: Tue Dec 05, 2006 11:41 pm    Post subject: RE: PHP extracting text from between two seperate points Reply with quote

It sounds like a job for a regular expression.
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
TonyLB
LXF regular


Joined: Tue Apr 12, 2005 8:08 pm
Posts: 112
Location: Wirral, UK

PostPosted: Wed Dec 13, 2006 10:59 pm    Post subject: RE: PHP extracting text from between two seperate points Reply with quote

If you can identify the end point as well, then use substr(string, start, length)
Find the start position s, the end position e
newString = substr(oldString, s+1, e-s)

Tony
_________________
In the beginning was nothing, which exploded! (Lords and Ladies, Terry Pratchett)
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
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
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast