str_replace & regular expressions question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mickey

    str_replace & regular expressions question

    Hi folks,

    I am just writing to ask for help with something i'm trying to do with
    a string.

    I have a filename, for instance 'file.txt'.
    However i'd like to make a script to take that file name and return it
    as something like:
    <a href= javascript:func tion('file.txt' )>file.txt</a><br />

    I have tried using PHP's str_replace function but I still can't seem to
    get it right.

    Does anyone know what I need to do to accomplish this?

    Thank you all in advance.

    Mikey

  • Vincent Courcelle

    #2
    Re: str_replace &amp; regular expressions question

    Mickey a écrit :
    [color=blue]
    > I have a filename, for instance 'file.txt'.
    > However i'd like to make a script to take that file name and return it
    > as something like:
    > <a href= javascript:func tion('file.txt' )>file.txt</a><br />[/color]

    Hello,
    It seems to easy to be what you expect but I try :
    function getLink($filena me)
    {return "<a
    href=\"javascri pt:function('". $filename."')\" >".$filename. "</a><br />";}

    --
    Vincent Courcelle
    http://www.tubededentifrice.com et http://www.france-jeunes.net

    Comment

    • Mickey

      #3
      Re: str_replace &amp; regular expressions question

      Thank you Vincent for that.
      That solution was blatantly obvious. I can't believe I didn't see it.

      Thank's again for the help.

      Kind Regards,
      Mikey

      Comment

      Working...