Forum Moderators: coopster

Message Too Old, No Replies

String value applies XYZ except for non-alpha-numeric characters?

         

JAB Creations

8:49 am on Jan 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The script below takes the text already given to it and makes all the characters lowercase, makes the first letter uppercase, and then limits the string to no more then 36 total characters.

However I am having a problem when it takes a non-alpha-numeric entity such as & and cuts it off mid-way for example. This creates a parsing error which disables my page served as application/xhtml+xml.

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

So what I want to do is tell the page to do the same thing EXCEPT when encountering non-alpha-numeric entities such as the amperstamp.

John

whoisgregg

9:26 pm on Jan 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could html_entity_decode() [php.net] the string be, then htmlentities() [php.net] the result?

I'm not certain if that would be more or less efficient than parsing the string for a &x; then branching your code, but I bet it would work. :)