b00ker_b0y Posted July 27, 2007 Share Posted July 27, 2007 hey people; got my self in a bit of a problem. I read from the database a piece of text i.e. "Hello one, two, three.<br><br>Click <a href='index.html'>here</a> now. Sentence 3. Setence 4." I use the the following code to basicly only take the first 3 sentences: $str_arr = explode(".",$data[Content]); $summary = $str_arr[0].".".$str_arr[1].".".$str_arr[2]; so i basicly just uses the full stops as like a end of line marker, but in the second sentence as part of the hyperlink there is a full stop which is being read as one, then messing up my output. Is there anyway i can ignore this full stop? or is there a way is can remove the link wothout removing the hyperlink text from the string? Help would be appriated! thanks. Quote Link to comment Share on other sites More sharing options...
b00ker_b0y Posted July 27, 2007 Author Share Posted July 27, 2007 bump Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 27, 2007 Share Posted July 27, 2007 you would need preg_split(); the regex would have to search for '.' that are not inside an a tag (you maybe want to control whether its in other tags too!!) $str_arr = preg_split('/(?!<a(.)*?>)(.)*?\.(.)*?(?!<\/a/)',$str); something like that (don't expect that to work straight off but someone much better at regex will correct me! ) Quote Link to comment Share on other sites More sharing options...
b00ker_b0y Posted July 27, 2007 Author Share Posted July 27, 2007 cheers buddy, you sent me in the right direction so i will do a bit of research! thanks again! 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.