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? edit: the final purpose of the script is to display the shortest 5 and longest 5 sentences in the text, if that matters at all
It looks like you may need regex $regex = '/(.+[\.!\?])\s/s'; $sentances = preg_split($regex, $text); var_dump($sentances); PHP: