SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Jul 2000
    Location
    North Central AR
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Making a variable..

    This is confusing me and hopefully I can explain it right or understandable.

    I have a variable that can be different values, but I do know all the value's it can be. I am trying to take this variable attach text letters to it to create another variable, and then echo this last variable on a html page.

    Example

    changing variable

    $color

    And I know all the values $color can be.

    If the value of $color is "red"

    attach letters to it like "body".

    I would then have $redbody

    And $redbody would be defined in a config file like:

    $redbody = "<body color=red>";

    Then I want to use that last variable name to echo to a html page like

    echo "$redbody";

    Or another time I would attach "link" to $color's value. If again it was "red" I would have $redlink and again $redlink is defined in the config file and I echo that.

    I know this seems strange, but this is the way I need to do it.
    Does this make sense? Any ideas how how to do this?
    Thank you.

    ronnie
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To get the body and link you can do:
    $bodyVar = $($color . "body");
    $linkVar = $($color . "link");

    A better way to organize this would be to use associate arrays or objects.

  3. #3
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or just use CSS....
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  4. #4
    SitePoint Addict
    Join Date
    Jul 2000
    Location
    North Central AR
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply Anarchos,

    I'm still having a problem with this. the thing is, from the example above, the end result which would be a variable called $colorbody , is already defined ina config file, $colorbody = "red";

    The problem is I can't echo the value of "$colorbody" all I keep getting is a echo of the variable name itself. I can't echo the value of the variable. Any ideas?

    Asp, don't think CSS would work, because I am doing more than just html/page layout.. Good idea though.
    ronnie
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can't you just do:

    <body bgcolor=$color>

    ???

  6. #6
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ronnie, $bodyVar and $linkVar contain the information you want...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •