Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> String/text Formatting?
wappy
post Sep 5 2006, 10:45 AM
Post #1


Premium Member
********

Group: Members
Posts: 164
Joined: 2-July 06
From: England
Member No.: 25,974



right i was wondering if someone could help me with this:
I notice on this site if i make a topic for example WAppY rOCks WaP, it will come out like Wappy Rocks Wap. I also want to do this to my forums, can anyone give me the code to format a string of text in this way?
THANKS IN ADVANCE
Go to the top of the page
 
+Quote Post
jlhaslip
post Sep 5 2006, 11:05 AM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,969
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



PHP has a selection of string modifying functions to handle this. In fact you will have to use two of them together in the following fashion:
CODE

<?php
$foo = 'HeLlO wOrLd!';
echo $foo;
$foo = ucwords(strtolower($foo));
echo $foo;
?>

Untested, but it should work exactly as you want. It is slightly modified from the php manual.
The strtolower function converts the entire string to lowercase and then the ucwords function converts the starting character of each word to uppercase. How and when and where these functions need to be applied to your Forum is another topic and would be dependent on the Forum specific coding. Essentially, use this code whenever the topic title is displayed.
Go to the top of the page
 
+Quote Post
wappy
post Sep 6 2006, 12:41 AM
Post #3


Premium Member
********

Group: Members
Posts: 164
Joined: 2-July 06
From: England
Member No.: 25,974



Many thanks :-)
i should of really looked at php.net for this (now i realise how simple it is).
Its just i made a mod for my wap forums where the latest replied to topic is shown above my forum categories. I (when making categories) use this format of writing but other users don't so i wanted to format it so it appears this way and matches my categories, just a small detail to make it look more professional.
Go to the top of the page
 
+Quote Post
jlhaslip
post Sep 6 2006, 01:08 AM
Post #4


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,969
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



The php Manual can be downloaded to your desktop / Laptop so that it is readily available even if you are off line at the time. It only takes a few minutes ant then you are never without it.
Go to the top of the page
 
+Quote Post
wappy
post Sep 6 2006, 10:10 AM
Post #5


Premium Member
********

Group: Members
Posts: 164
Joined: 2-July 06
From: England
Member No.: 25,974



Yes i know this but i work from a symbian phone (nokia 6630) and have built my site and also browse with this. I have a pc but its broken and i won't have money to fix it for a while. So i can't really use the php manual on this as i believe its like a 2mb file, if i open a file so big while im browsing it will slow me down way to much. But yes i will download it anyway. I find the web site more helpfull though with its search and examples :-)
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Garbage Text(2)
  2. Problem With Firefox Text Alignment(9)
  3. Dynamic Image / Signature Generator(12)
  4. Simple Text Counters(15)
  5. Help Php: How To Load String From Text File (solved)(9)
  6. Problems With Data Formatting(2)
  7. Forms, Text Files, And Php For A Signature Generator.(1)
  8. [php]simple Flat File Text Manipulator(3)
  9. Php Text Editor(1)
  10. I Just Wrote A Script For A Php Text Editor!(8)


 



- Lo-Fi Version Time is now: 30th August 2008 - 03:20 AM