Forum Moderators: coopster

Message Too Old, No Replies

Applying three commands to the same string?

         

JAB Creations

1:16 pm on Dec 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All I'm trying to do is keep this string under 36 characters, stop all caps screaming, and then ensure the first letter of each word is uppercase.

Here is the code as I figured it should look.

$mail['shortsubject'] = trimtext($mail['subject'], 36) && ucfirst($mail['subject']) && strtolower($mail['subject']);

John

jc_armor

2:11 pm on Dec 29, 2005 (gmt 0)

10+ Year Member



i think it should be:

$mail['shortsubject'] = substr(ucwords($mail['subject']),0,36);

surfin2u

2:12 pm on Dec 29, 2005 (gmt 0)

10+ Year Member



how about:

$mail['shortsubject'] = ucwords(strtolower(substr($mail['subject'], 0, 36)));

sonjay

2:15 pm on Dec 29, 2005 (gmt 0)

10+ Year Member



$mail['shortsubject'] = ucwords(strtolower(substr($mail['subject'], 0, 36)));

is also what I came up with.

JAB Creations

2:22 pm on Dec 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Different from my approachs, I was trying to combine them using the && operator.

I will try these out and post in a minute or two if they work, thanks for the quick replies! :)

JAB Creations

2:25 pm on Dec 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Coolbeans, this worked...

$mail['shortsubject'] = ucwords(strtolower(substr($mail['subject'], 0, 36)));

How can I add three dots at the end of the string?

Thanks for ALL the suggestions. :)

John

Romeo

4:45 pm on Dec 29, 2005 (gmt 0)

10+ Year Member



How can I add three dots at the end of the string?

$mail['shortsubject'] = ucwords(strtolower(substr($mail['subject'], 0, 36))) . ' ...';

Regards,
R.