SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: regex

  1. #1
    SitePoint Wizard jumpthru's Avatar
    Join Date
    Apr 2000
    Location
    Los Angeles, California
    Posts
    1,008
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want the following to work

    Code:
    $pagetext=eregi_replace("\[adminheader]", adminheader(), $pagetext);
    but instead of only running adminheader() where [adminheader] is, it runs it whether its their or not...how do I do this?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well what does the function do? does it return the result or does it print it? I imagine if you just return to the result and not print it within the function it would only show up if the presence of [adminheader] was found.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Zealot
    Join Date
    Nov 1999
    Location
    Manhattan!
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The adminheader() function will be called when the eregi_replace() function is evaluated.

    A couple of things you can do:
    1) If adminheader() simply returns a text string, modify your eregi_replace() to contain that text string instead of the function.

    2) If you are calling admindeader() for a side affect, try using stristr() instead to see if [adminheader] is in the string.

    3) If adminheader() returns a text string that is unique depending on the context, first use stristr() to check if the substring is contained, then call admin header and store the result in a string variable and finally use eregi_replace() to insert the text string.

    Christian
    www.Christian.Reimer.com
    A personal website exploring the mental summersaults,
    odd occurrences and political powerplays in the land of me.

  4. #4
    SitePoint Wizard jumpthru's Avatar
    Join Date
    Apr 2000
    Location
    Los Angeles, California
    Posts
    1,008
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I ended up doing the following.

    the functoin adminheader calls the database and gets something out...and then returns it.

    so what i did was just do a eregi and if it was true then run $tmp=adminheader(); then i just did my eregi_replace and replaced it with $tmp.


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
  •