how do i write a function for capitalizing the first letter of a sentence using
explode or preg_replace_callback?
have written this:
Code: Select all
<?php
$split=explode(".",$str);
for($i=0; $i<count($split); $i++)
{
$temp[$i]=ucfirst(trim($split[$i]));
}
$output = implode(".",$temp);
return $output;
?>it trims spaces in output and does not use capitalise letters in sentences after ? or !
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: