How to split text to match double quotes plus trailing text to dot?

Viewed 350

How can I get a sentence that is in double quotes in which there is a dot that must be split?

Example document like this:

“Chess helps us overcome difficulties and sufferings,” said Unnikrishnan, taking my queen. “On a chess board you are fighting. as we are also fighting the hardships in our daily life.” he said.

I want to get output like this:

Array
(
    [0] =>"Chess helps us overcome difficulties and sufferings," said Unnikrishnan, taking my queen.
    [1] =>"On a chess board you are fighting. as we are also fighting the hardships in our daily life," he said.
 )

My code still explode by dots.

function sample($string)
{
    $data=array();
    $break=explode(".", $string);
    array_push($data, $break);

    print_r($data);
}

I'm still confused to split two delimiter about double quote and dot. because inside double quote there is a sentence that contain dot delimiter.

3 Answers
Related