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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:24:32+00:00 2026-05-24T12:24:32+00:00

This is going to be pretty hard to explain, so I’ll try to make

  • 0

This is going to be pretty hard to explain, so I’ll try to make it as much of a chronological story as possible and end with the question, so that anyone who needs a relatively in-depth idea of what I’m talking about has one :).

I have a theme template with four text containers named primary_headline, primary_subline, secondary_headline and secondary_subtext. The content for each container comes from echo($container_name).

Each container has it’s own variable, $container_name, which posts user created content to from a form, contents which sometimes contains the variables $city_name and $ref_name as raw data (i.e. “Hello, I’m from $city_name”), as $city_name and $ref_name has assigned values, for arguments sake let’s just say $city_name= Dallas and $ref_name = Facebook.

Originally, I believed that I only wanted the user to be able to use $city_name and $ref_name within the secondary_subtext container, and I was also going to make the option to use $city_name OR $ref_name the choice of the user in the first place (they’d have to select one, or the other, or none – but couldn’t select both.

However, I now want to allow $city_name AND $ref_name across all four container variables ($secondary_subtext for example).

So, my question is, how do I go about doing that in the easiest possible fashion?

Here’s my old code for good measure:

if($geo_text == "enable") {
    $geo_init = include("inc/geo_text.php");
    $secondary_headline = str_replace('$city_name', $city_name, $_POST['secondary_headline']); // $_POST data from user
} else($ref_text == "enable") {
    $ref_init = include("inc/ref_text.php");
    $secondary_headline = str_replace('$ref_name', $ref_name, $_POST['secondary_headline']); // $_POST data from user
} else { $secondary_headline = $_POST['secondary_headline']; }

Any comments/answers etc will be very greatly appreciated :)!!

  • 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-24T12:24:32+00:00Added an answer on May 24, 2026 at 12:24 pm
    $placeholders = array('city_name','ref_name');
    $include_mapper('geo_text' => 'inc/geo_text.php','ref_text'=>'inc/ref_text.php');
    $containers = array('first_headline','scondary_headline');
    
    $found = 0;
    foreach ($include_mapper as $map => $include){
        if ($$map == "enable"){
            include ($include_mapper[$map]);
            foreach ($container as $container){
                foreach ($placeholders as $placeholder){
                    $$container = str_replace('$'.$placeholder, $$placeholder, $_POST[$container];
                }
            }
          $found = 1;
          break;
        }
    }
    if (!$found){
        foreach ($container as $container){
            $$container = $_POST[$container];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is going to be hard to explain but I'll try my best. I
I imagine this is a pretty hard question to answer without sitting down and
Unfortunately this is going to be a pretty open-ended question, but I am at
I find this pretty confusing. When you want to rotate a view, it's going
This is going to sound like a silly question, but I'm still learning C,
This is going to be a little tricky to explain. I'm trying to write
This is going to sound too silly / too basic - sorry about that,
This might seem like a pretty detailed question about Easymock, but I'm having a
My question is pretty straightforward: You are an executable file that outputs Access granted
I'm currently making a note web app that going pretty well. I have the

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.