Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Turning text into Sentence Form

Featured Replies

Is there a variation of ucfirst () which will convert to sentince form - ie Capitalises after every full stop (.) but leaves already existing words capitalised?

 

so

 

hi I am enjoying the Webdesigners forum. it's really cool.

 

would change to:

 

Hi I am enjoying the Webdesigners forum. It's really cool.

  • 2 weeks later...
Is there a variation of ucfirst () which will convert to sentince form - ie Capitalises after every full stop (.) but leaves already existing words capitalised?

 

so

 

hi I am enjoying the Webdesigners forum. it's really cool.

 

would change to:

 

Hi I am enjoying the Webdesigners forum. It's really cool.

 

You would need to use explode() with full stops. I've had a quick look on the PHP site and found this posting...

 

<?php

$text="this is a sentence. this is another sentence.";

$split=explode(". ", $text);
foreach ($split as $sentence) {
$sentencegood=ucfirst($sentence);
$text=str_replace($sentence, $sentencegood, $text);
}

echo $text; // This is a sentence. This is another sentence.

?>

 

Not tested it, but looks like it should work.

 

Good luck!

Nice one Paul .. I took a shot at the code too ... here's my solution (with comments too):

 

//you should explode the dot only with no spaces
//you could also transform the text to lowercase (just in case you have "tHiS is a seTence.this is another.")

$split = explode(".", strtolower($text)); 
foreach ($split as $sentence) 
{
//here I'm building an array with sentences, uppercasing the first letter and removing unnecessary left/right spaces
$sentence2[] = ucfirst(trim($sentence));
}
//you can implode the array with the dot+space and also remove the last space
$text = rtrim(implode(". ",$sentence2));

echo $text; //This is a sentence. This is another sentence.

 

PHP is fun ^_^

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.