calling a function through user input.

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

    calling a function through user input.

    Hey guys.
    So heres yet another question to a problem where I would have no idea
    where to look for the answer for so I turn to you :)

    Say my sites administrator wants to write a news update or blog or
    whatever. Something like this

    "Added a new gallery from my trip to Phuket, enjoy:
    [GID=24]
    If you liked it tell me."

    I want the [GID=24] to get replaced by my galery loading function
    (very nifty and handy) so it would turn into something like this

    echo "Added a new gallery from my trip to Phuket, enjoy:
    ".galery($GID). "
    If you liked it tell me.";


    I chose this [GID=24] because it is similar to burning board code. I
    would also like to include a command like [PID=45] witch would run my
    picture function.

    any ideas what functions I am looking for?

    bless

  • Bocah Sableng

    #2
    Re: calling a function through user input.

    On May 4, 12:09 pm, Mohawk Mawk <blessblessbl.. .@gmail.comwrot e:
    Hey guys.
    So heres yet another question to a problem where I would have no idea
    where to look for the answer for so I turn to you :)
    >
    Say my sites administrator wants to write a news update or blog or
    whatever. Something like this
    >
    "Added a new gallery from my trip to Phuket, enjoy:
    [GID=24]
    If you liked it tell me."
    >
    I want the [GID=24] to get replaced by my galery loading function
    (very nifty and handy) so it would turn into something like this
    >
    echo "Added a new gallery from my trip to Phuket, enjoy:
    ".galery($GID). "
    If you liked it tell me.";
    >
    I chose this [GID=24] because it is similar to burning board code. I
    would also like to include a command like [PID=45] witch would run my
    picture function.
    >
    any ideas what functions I am looking for?
    >
    preg_replace_ca llback()

    HTH

    Comment

    • Rami Elomaa

      #3
      Re: calling a function through user input.

      "Mohawk Mawk" <blessblessbles s@gmail.comwrot e in message
      news:1178255378 .399380.81860@p 77g2000hsh.goog legroups.com...
      Hey guys.
      So heres yet another question to a problem where I would have no idea
      where to look for the answer for so I turn to you :)
      >
      Say my sites administrator wants to write a news update or blog or
      whatever. Something like this
      >
      "Added a new gallery from my trip to Phuket, enjoy:
      [GID=24]
      If you liked it tell me."
      >
      I want the [GID=24] to get replaced by my galery loading function
      (very nifty and handy) so it would turn into something like this
      >
      echo "Added a new gallery from my trip to Phuket, enjoy:
      ".galery($GID). "
      If you liked it tell me.";
      >
      >
      I chose this [GID=24] because it is similar to burning board code. I
      would also like to include a command like [PID=45] witch would run my
      picture function.
      >
      any ideas what functions I am looking for?
      preg_replace_ca llback()


      example:
      preg_replace_ca llback('/\[GID=([\d]+)\]/', 'galery', $input);

      But galery will recieve an array of matches, not just an id, so you'll maybe
      need to modify it a bit. Also I haven't tested this at all, the example is
      just to illustrate the idea...


      --
      Rami.Elomaa@gma il.com

      "Good tea. Nice house." -- Worf


      Comment

      • Mohawk Mawk

        #4
        Re: calling a function through user input.

        >But galery will recieve an array of matches, not just an id, so you'll maybe
        >need to modify it a bit. Also I haven't tested this at all, the example is
        >just to illustrate the idea...
        thank you very much, I inserted a handling function:


        function garray($input){
        return gallery($input[1]); /* $input[0] is '[GID=X]' and $input[1]
        is 'X' */
        }

        $news="See my galleries one [GID=1] and two [GID=2]";
        echo preg_replace_ca llback('/\[GID=([\d]+)\]/', 'garray', $news);

        it works like a charm, this is the beginning of a whole bunch of new
        possibilities for the administrator to write news.
        thank you very much

        Comment

        Working...