mcrae Posted December 15, 2007 Share Posted December 15, 2007 Hello everyone, I'm really new to php, here is what I want to do. Search through a body of text, untill it reaches "." "!" or "?" followed by single or double quotes, or a space. then put all text its gone through so far into the first array element. Then start over from that position. I was trying to do it like this: $url = explode("[.|/?|!] ", $_REQUEST["text"]); but it wasn't working, I can only get it to work for a single punctuation, and then the data in the arrays doesn't have punctuation, which is a bad thing. Can anyone help please? The final purpose of the script is to display the shortest 5 and longest 5 sentences in the text, if that matters at all Quote Link to comment Share on other sites More sharing options...
Barand Posted December 15, 2007 Share Posted December 15, 2007 use split() instead of explode(). www.php.net/split You still lose the final punctuation but that won't affect your final purpose to find shortest and longest Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted December 15, 2007 Share Posted December 15, 2007 yeah to elaborate it'd be something like: <?php $sentences = split('[.|/?|!] ', $string); print '<pre>'; print_r($sentences); print '</pre>'; ?> 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.