I am having the following example string:
$string = "Mr.Bean said: It must be great to know PHP.
He added that IP 1.2.3.4 is the best IP address one could own.
Mrs. Walter. Today is a wonderful day. Tomorrow, it will rain.
This is really just some random text. Did you hear this singing bird?
I visited Berlin yesterday. It was raining and Mr. Bean said hello.
Mrs. Bean was also there. They have two kids.";
What I need is a way to add two br's (line break) each time when three dots were in the string while making sure it does not add the br's if the word before the dot is less than 4 characters so it does not split things like Mr. Mrs. Dr.
The result I am looking for based on the string above would be:
Mr.Bean said: It must be great to know PHP. He added that IP 1.2.3.4 is the best IP address one could own. Mrs. Walter.
Today is a wonderful day. Tomorrow, it will rain. This is really just some random text.
Did you hear this singing bird? I visited Berlin yesterday. It was raining and Mr. Bean said hello. Mrs. Bean was also there.
They have two kids.
So what I am basically looking for is a function like:
$string = SplitString($string);
which would take care of the format that I am looking for.
UPDATE:
The posted solution works fine, except that domain names are split also.
Example string where it shows the issue:
Bill Price reveals his new method for playing the diatonic harmonica, whereby anyone can convert their ordinary ten-hole diatonic harmonicas into lead instruments. “Coupling is a patented method; guaranteed to expand the harmonica's range and over-all capability.” The major key diatonic coupling formula for this method is disclosed at: http://example.com/. You’ll enjoy samples from Bill’s unique ten-song CD, “Taking the Lead”. This CD displays dynamic possibilities available when pairing/coupling two diatonic harmonicas together. The result is truly astonishing! The formula is free for visiting example.com. The CD is only $8, plus it can be used as a tutorial for learning the Coupling Method.
The snippet splits it like this:
Bill Price reveals his new method for playing the diatonic harmonica, whereby anyone can convert their ordinary ten-hole diatonic harmonicas into lead instruments. “Coupling is a patented method; guaranteed to expand the harmonica's range and over-all capability.” The major key diatonic coupling formula for this method is disclosed at: http://example.
com/. You’ll enjoy samples from Bill’s unique ten-song CD, “Taking the Lead”. This CD displays dynamic possibilities available when pairing/coupling two diatonic harmonicas together.
The result is truly astonishing! The formula is free for visiting example.com. The CD is only $8, plus it can be used as a tutorial for learning the Coupling Method.
Besides that, it seems to work perfect! Maybe the trick is somehow to check if there is a space after the dot to prevent domains from being split?