SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hard to explain eregi_replace problem

    Hello,
    I have a problem which I'm stumped on.

    I have to replace a text string like {!articledropdown!} with the contents of the $article drop down variable. Sounds simple but it isn't. Part of the variable name comes from a variable which is where I'm stuck.

    Here's an example:

    $contents = eregi_replace ("{!articledropdown!}","$articledropdown", $contents);

    That works fine but I need to figure a way out for it to do this:

    $contents = eregi_replace ("{!".$variable."dropdown!}","$$variabledropdown", $contents);

    Where it insterts the $variable value into another variable is what has me stuck. Can anyone help?

    Does that make any sense at all? I can't explain it very well.

    Thanks for your help,
    Justin Sampson
    Last edited by Justin Sampson; Sep 22, 2001 at 17:26.

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, try this:

    PHP Code:
    $var "${variable}dropdown";
    $contents str_replace("{!${variable}dropdown!}", $$var$contents); 
    Last edited by TWTCommish; Sep 22, 2001 at 18:18.

  3. #3
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Waho! It works!

    Thanks TWT!

  4. #4
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem, glad to help! Hmmm, now if only Karma were still in place.


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
  •