报价搜索此代码的在线文本编辑

This is the main quotation search link: https://englishact.com/onlinequotationsearch/

This is the database: enter image description here

This is the code to display search result:

echo ucfirst(str_replace($put,$putt,$quot1[$i]['quot']))."<br><b><i> - ".ucfirst(str_replace($put,$putt,$quot1[$i]['author']))."</i></b><hr><br>";

Problem

All my database data (quots) are lowercase. So, I tried to use ucfirst to make initial sentence's letter uppercase. But problem is arising for quotations with more than one sentence.

For an example:

If you press search button keeping quotation in the input box you will get one quotation

Stay at home in your mind. don't recite other people's opinions. i hate quotations. tell me what you know. - Ralph Waldo Emerson

Which is incorrect. It should be -

Stay at home in your mind. Don't recite other people's opinions. I hate quotations. Tell me what you know. - Ralph Waldo Emerson

So, is there any way to capitalize beginning letters of every sentences?

    $str = $quot1[$i]['quot'];

    //now capitalize every letter after a . ? and ! followed by space
    $str = preg_replace_callback('/[.!?] .*?\w/', 
      create_function('$matches', 'return strtoupper($matches[0]);'), $str);



echo ucfirst(str_replace($put,$putt,$str))."<br><b><i> - ".ucfirst(str_replace($put,$putt,$quot1[$i]['author']))."</i></b><hr><br>";