Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6570057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:42:32+00:00 2026-05-25T14:42:32+00:00

I have a complicated problem: I have a very long text and I need

  • 0

I have a complicated problem:
I have a very long text and I need to call some php functions inside my text.
The function name is myfunction();
I`we included in my text the function in the following way:
” text text text myfunction[1,2,3,4,5]; more text text … “

And I want to replace each myfunction[…] with the result of the function myfunction with the variables from the [] brackets.

my code is:

<?php echo preg_replace('/myfunction[[0-9,]+]/i',myfunction($1),$post['content']); ?>

,but it`s not working.

The parameter should be an array, because it can contain any number of values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:42:32+00:00Added an answer on May 25, 2026 at 2:42 pm

    If I were you, I would avoid using the e modifier to preg_replace because it can lead you open to execution of arbitrary code. Use preg_replace_callback instead. It’s slightly more verbose, but much more effective:

    echo preg_replace_callback('/myfunction\[([0-9,]+)\]/i', function($matches) {
        $args = explode(',', $matches[1]); // separate the arguments
        return call_user_func_array('myfunction', $args); // pass the arguments to myfunction
    }, $post['content']);
    

    This uses an anonymous function. This functionality won’t be available to you if you use a version of PHP before 5.3. You’ll have to create a named function and use that instead, as per the instructions on the manual page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK. I have a very long and pretty complicated function. It looks almost like
Im having a very strange problem, i have a complicated view that returns incorrect
I have a very weird problem with core text, which sometimes randomly and sometimes
I have a very complicated problem that occurs only for non-admin windows user. I
I have complicated query over very big table. Long story short, when I use
I have a complicated problem and I hope to explain it clearly possible... I
I have a problem with (for me to complicated) MySql query. Okay, here is
I have the following tricky problem: I have implemented a (rather complicated) class which
Alright, this problem is a little complicated, so bear with me. I have a
I have a complicated report that I need to draw with GDI+ (I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.