PDA

View Full Version : Capitalize the first letter of each sentence.


Guy G
01-28-2005, 08:32 PM
In the title.
Anyone knows how to?

Andy
01-29-2005, 06:40 AM
Edit newthread.php and change the following line

$newpost['title'] = $_POST['subject'];

to

$newpost['title']=strtoupper($_POST['subject']{0}).substr($_POST['subject'], 1);

Guy G
01-29-2005, 06:45 AM
$newpost['title']=strtoupper($_POST['subject']{0}).substr($_POST['subject'], 1);

That didnt work.
But this wont do what i need as well. It willl only capitalize the 1st letter and not the letter at the start of a new sentence...

Tekton
01-29-2005, 06:48 AM
:surprised: EACH sentence? (in the title?) so every time it finds a .(period) in a post it's supposed to strtoupper the next character regardless of whether or not it's a sentence?

How many sentences do you put in your titles?

Guy G
01-29-2005, 06:51 AM
:surprised: EACH sentence? (in the title?) so every time it finds a .(period) in a post it's supposed to strtoupper the next character regardless of whether or not it's a sentence?

How many sentences do you put in your titles?
oooo no...

you both didnt get me right.... sorry my bad..
when i ment "in the title" i ment the question is in the title of the thread.
i want to apply this on the message itself..

Tekton
01-29-2005, 07:03 AM
Oh, you mean your question is in the title... confusing~

So you want to capitalize the letter after a period regardless of why the period is used?

Guy G
01-29-2005, 07:06 AM
Oh, you mean your question is in the title... confusing~

So you want to capitalize the letter after a period regardless of why the period is used?
Yes. Basically...

You think it might have problems or something?

Tekton
01-29-2005, 07:20 AM
Well I just don't see the use/need for it. Also it could cause a little oddity in links with dots (among other things I suppose) -- not that it'd do actual harm in most cases...

Guy G
01-29-2005, 07:28 AM
Well I just don't see the use/need for it. Also it could cause a little oddity in links with dots (among other things I suppose) -- not that it'd do actual harm in most cases...
>.<

Well thanks anyway, ill just use the one Andy wrote and apply onto the message.

Tekton
01-29-2005, 07:44 AM
Link?

If you add this after the require of global.php in newreply.php and newthread.php, it should work:


$xr=0;$rvrt=0;
while($xr<strlen($_POST[message])){
if($rvrt==1){$_POST[message]{$xr}=strtoupper($_POST[message]{$xr});}
if($_POST[message]{$xr}=="."||$_POST[message]{$xr}==" "&&$rvrt==1){$rvrt=1;}else{$rvrt=0;}
$xr++;}

Guy G
01-29-2005, 09:43 AM
Link?

If you add this after the require of global.php in newreply.php and newthread.php, it should work:


$xr=0;$rvrt=0;
while($xr<strlen($_POST[message])){
if($rvrt==1){$_POST[message]{$xr}=strtoupper($_POST[message]{$xr});}
if($_POST[message]{$xr}=="."||$_POST[message]{$xr}==" "&&$rvrt==1){$rvrt=1;}else{$rvrt=0;}
$xr++;}

it works good!
but there are some things...
1. it doesnt capitalize the first letter like i used to according to what Andy wrote which i have modded to the message...

2.it does capitalize when you go down a line...


here look at this post:
http://forum.ex-zone.com/showpost.php?p=581&postcount=7

Tekton
01-29-2005, 10:12 AM
Ah, I forgot other punctuation marks...


$_POST[message]=strtoupper($_POST[message]{0}).substr($_POST[message], 1);
$xr=0;$rvrt=0; while($xr<strlen($_POST[message])){
if($rvrt==1){$_POST[message]{$xr}=strtoupper($_POST[message]{$xr});}
if($_POST[message]{$xr}=="."||$_POST[message]{$xr}==" "&&$rvrt==1||$_POST[message]{$xr}=="?"||$_POST[message]{$xr}=="!"){$rvrt=1;}else{$rvrt=0;}
$xr++;} (added in first char too)

you WANT it to capitalize on new lines too?

Guy G
01-29-2005, 10:19 AM
you WANT it to capitalize on new lines too?
only if a period came before.

It works great just the next line thing...

Cristi_XP
03-03-2008, 04:36 AM
works great ! Thanks a lot !!!
but i am having trouble with links posting,after . it puts the extension with capital letter,and the link doesn`t work