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 9182487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:34:16+00:00 2026-06-17T18:34:16+00:00

I know a bit about Regular Expression but really want to learn more about

  • 0

I know a bit about Regular Expression but really want to learn more about it and now i’m trying to make a function that detects all {} in my content (from a database) and checks what between the brackets. If there is a POST or GET with a name (format: POST:name or GET:name} i would like to replace them with that value.

Example:
When i have a form with the following inputs:

Name
Email
Message

And then in the value attribute i type: {POST:Name}
Then the script must detect the {POST:Name} and will replace it with the string in $_POST['name']. I already searched on Google, but found too much that i don’t know what to really use.

Now i have:

<?php
        preg_match_all("/{(POST|GET):[.*](})/", $content, $matches, PREG_SET_ORDER);

        foreach($matches AS $match)
        {
            if(isset($_POST[$match]))
                $content = str_replace('{POST:'.$match, $_POST[$match], $content);
            else
                $content = str_replace('{GET:'.$match, $_GET[$match], $content);
        }

?>

But this don’t work.

  • 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-06-17T18:34:18+00:00Added an answer on June 17, 2026 at 6:34 pm

    You should use preg_replace, better than str_replace.
    And if you use preg_replace, you don’t need no more your first condition, et can do the same code with only one instruction.

    https://www.php.net/preg_replace

    <?php preg_replace('#{(POST|GET):(.*)}#','$_$1[$2]',$content); ?>
    

    My regex can be false, but something like this should work.

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

Sidebar

Related Questions

I know a little bit about TextWatcher but that fires on every character you
I want to know a bit more about 'xmlns:mx=http://www.adobe.com/2006/mxml. Generally namespaces acts as the
I really just wanted to know a bit more about the PHP Cli with
I know a bit about PHP, but never studied in depth, but now I
I know a bit about assembly programming in Microchip PIC micro controllers, but I
Pretty confused right now, while i feel i know a bit about vhosts this
I don't know very much about css, but i'm a tid bit stuck. I
I know a bit about MySQL, but not enough to know why this query
Sorry for the noobie and stupid question, but I know only a bit about
I know a little bit about how floating-point numbers are represented, but not enough,

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.