HOME       >>       Programming

String/text Formatting?


wappy

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


jlhaslip

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:

<?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.


wappy

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.


jlhaslip

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.


wappy

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 :-)



VIEW ORIGINAL REGISTER GET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.