Jul 25, 2008

String/text Formatting?

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

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 ADVANCEClick to view attachment

Reply

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

Reply

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.

Reply

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.

Reply

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

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : string, text, formatting

  1. I Just Wrote A Script For A Php Text Editor!
    (8)
  2. Php Text Editor
    (1)
    Is there any possible way using XML and PHP that you could create a text editor that can save files
    in your documents and also make a hotlink to your site. Much like a online notepad. I would like to
    know how I would make on of these and whether or not MySQL or XML would be a good language to use
    for storing data. My current idea deals with only PHP and iframes. It really isn't an editor
    though, more like a notes page. I would like a way though to be able to create a database with info
    stored from the PHP script which and be able to save to your hard drive. Also, i....
  3. [php]simple Flat File Text Manipulator
    Example on how to use forms to write to files in PHP (3)
    I made a simple flat file text editor, that can show you probably how simple it is to use forms with
    php and write that data to file. This example has 2 files, submit.php, and postit.html. Submit.php
    is used to write title, and some text, and add html tags, and paragraph tags where new paragraphs
    are. Here's the file with comments. I think that HTML really doesn't need some more
    explaining. CODE Title: <br /> <input type="text"
    name="title" size="53"> <br /> Text: <br />
    <textarea nam....
  4. Forms, Text Files, And Php For A Signature Generator.
    Help a little. (1)
    Hello everyone! I am in need of some code a for a signature generator I am making. I am using
    BuffaloHELP's code for the php file, now I am trying to improve that code by making a form in a
    html file that will have the user say what is on the sig! But now, I need help getting the form
    data that is posted by the user to get into that sig! There is a file, sig.txt, where that tells
    the php file what text will go on the sig. But how can I make the form data in the html file go into
    the text file so it will go onto the sig? You might want to read BuffaloHELP&....
  5. Problems With Data Formatting
    (2)
    I have a MySQL database which stores articles. A sample article would look like this: CODE This
    is a body. This is a body.This is a body.This is a body.This is a body.This is a body.This is a
    body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This
    is a body.This is a body.This is a body.This is a body. This is a body.This is a body.This is a
    body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This
    is a body.This is a body.This is a body.This is a body.This is a body. That'....
  6. Help Php: How To Load String From Text File (solved)
    Loading string from text file when you click on your link (9)
    I learned the way to load other files with the code posted on this forum. Now i wanted to try
    something for my side menu. I am calling this a string, --> $tekst , maybe it's
    called something else i'm not sure Now let's say i have a file called details.txt In that
    file i would like to have something like this $detailsaboutphp1 = ("details details details
    1"); $detailsaboutphp2 = ("details details details and even more details 2"); How to make a
    code that loads those $strings on click of a mouse. When we tried to load extern....
  7. Simple Text Counters
    Counters i use on wap sites ;-) (15)
    First create a dir "counters" in root add to it dailyhits.txt, hits.txt, online.txt an CHMOD 0777,
    place this on index: CODE //online counter $tim = 120+time(); $time =
    time(); $f = "counters/online.txt"; $nusk = file($f);
    $sk = count($nusk); $in = $HTTP_USER_AGENT.$REMOTE_ADDR; $fp =
    fopen($f, "w+"); for($i=0; $i<$sk; $i++) {
    list($nix, $timf) = explode("|", $nusk[$i])....
  8. Dynamic Image / Signature Generator
    a simple code to change text on an image (12)
    In search of dynamically changing quote, saying or all other types of text on an image I came across
    a code that I have modified to fit my initial usage. This procedure requires two files and short
    knowledge of PHP. If you are familiar with Trap17's sig rotation code you will understand this
    procedure very fast. Code 1: dynamic_sig.php (you can rename this to index.php and you'll see
    at the end why) Code 2: a simple text file named anything (I will call it name.txt ) Code 1
    CODE <?php header("Content-type: image/png"); �....
  9. Problem With Firefox Text Alignment
    (9)
    I just have a really simple annoyin prob with my site which I have only just noticed. If i view the
    site in IE the alignment is fine but when in Firefox it isnt properly aligned. The user searches the
    db and it returns a table with the results.. PHP Code: CODE echo '<br><table
    width="871" border="0" align="center" cellpadding="0"
    cellspacing="0"><tr><font face="Verdana, Arial, Helvetica,
    sans-serif" size="2"><strong>'; echo 'Artists beginning with
    '.$....
  10. Garbage Text
    when i added php includes to a page (2)
    When i added php included to a page, it produced this really really weird garbage text befor and
    after the table i have on the page. I was wondering if this has ever happened to anyone else. Not
    sure what's producing the gargabe, i mean it's only a couple of characters, and i've
    gone through everything and can't find anything. The other thing is that i can, and have gotten
    rid of it by getting rid of the text befor the php include code which isn't a solution becasue i
    want to keep the meta's and title on the page. this is what the garbage looks li....
  11. Write Random Text To Image
    PHP script help! (5)
    I'm trying to create a script that writes text to an image. CODE
    header("Content-type: image/png"); $_phrases = array( "Test 1",
    "Test 2", "Test 3", "Test 4", "etc." ); $_rand_phrase =
    $_phrases[rand(0,count($_phrases)-1)]; $_image =
    imagecreatefrompng("gmail.png"); $_user_width =
    imaagettfbbox(9,0,"tahoma.ttf",$_rand_phrase); $_x_value =
    (200-($user_width[2] + 113)); ....
  12. Help Importing Mysql Database Results
    Need help formatting link (3)
    I am having trouble formatting my table to display the results of a mySQL query the way I want.
    Here is the part of my code: CODE $result = mysql_query("SELECT * FROM uploads
    WHERE Category='Drama'") or die(mysql_error()); ?> <table
    cellspacing="2" cellpadding="2"> <tr> <th>Title</th>
    <th>Author</th> <th>File</th></tr> <?php // keeps
    getting the next row until there are no more to get while($row = mysql_fetch_array....

    1. Looking for string, text, formatting

Searching Video's for string, text, formatting
advertisement



String/text Formatting?



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE