Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8

Thread: PHP Help

  1. #1
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    This is pretty hard to explain...

    i made this code which will get the username and then display it in a different colour...
    PHP Code:
    else if ( $row['username'] == AnExample
    {
    $row['username'] = '<span class="blue">' $row['username'] . '</span>';

    but what i really want to do is display the username like this
    Code:
    AnExample
    
    <span class="blue">An</span>Example
    now crunch time, is there any way to do this using php?
    JR

  2.  

  3. #2
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    string functions... www.php.net look for string search/splitters...
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  4. #3
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    thanks, if i figure it out i will award you the tenner
    JR

  5. #4
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    no i don't understand, i don't like www.php.net it doesn't explain very well
    JR

  6. #5
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    i tried this...

    PHP Code:
    if ( $row['username'] == AnExample)
    {
    split('</span>'$row['username'], 2);
    $row['username'] = '<span="blue"><b><em>' $row['username'] . '</em></b>'

    didn't work
    JR

  7. #6
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    Sorry I couldn't help ya earlier - class time.

    I don't know exactly the uses of your code... but here's one possible solution:

    Code:
    if ($row['username'] == "AnExample")
    {
    $formatted = "<span class='blue'>" . substr($row['username'], 0, 1) . "</span>" . substr($row['username'], 2);
    }
    First off I got this from: http://us3.php.net/manual/en/function.substr.php

    The function substr returns part of a string, the first number is the number (remember, starts with zero i.e.e "abcdef" a(0) b(1) c(2) d(3) e(4) f(5) ) that it starts with the second (optional) is the one it ends on. So it grabs the first two letters, then grabs everything from the third letter on.

    HOpe this helps.
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  8. #7
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    thanks
    JR

  9. #8
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    Glad I can help
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:35 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com