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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:25:05+00:00 2026-05-12T13:25:05+00:00

I want to make a conditional if statement that does this if($get_[‘b’]==1) { $offer1a=$offer1XXX;

  • 0

I want to make a conditional if statement that does this

if($get_['b']=="1") {

$offer1a=$offer1XXX;
$offer1e=$offer1YYY;

$offer2a=$offer2XXX;
$offer2e=$offer2YYY;

$offer3a=$offer3XXX;
$offer3e=$offer3YYY;

$offer4a=$offer4XXX;
$offer4e=$offer4YYY;

}

All the way to offer #12. It seems like a lot to write out. There are other values like $offer1b that I want left alone. What’s the best way to do this. I think an array, but I’m unclear on how to get it done.

  • 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-12T13:25:05+00:00Added an answer on May 12, 2026 at 1:25 pm

    I’m sure there are a thousand more optimizations, but to do literally what you’re asking, you could use a for loop as such:

    if ($_GET['b'] == 1) {
      for ($k = 1; $k <= 12; $k++) {
        ${"offer${k}a"} = ${"offer${k}XXXX"};
        ${"offer${k}e"} = ${"offer${k}YYYY"};
      }
    }
    

    A better solution would be to use an array instead of all these individual variables:

    for ($k = 1; $k <= 12; $k++) {
      $offers[$k]['a'] = $offers[$k]['XXXX'];
      $offers[$k]['e'] = $offers[$k]['YYYY'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a select statement where I want to make the select conditional like
I want to know how to make an if statement that executes a clause
I want to make sure that all 3 conditions result in the same answer
Im trying to create a conditional statement that iterates through an array of nodes
I want make datetimepicker in my project. Using jquery how it is possible? I
I want make a bash script which returns the position of an element from
I want make interactive application where user launches it and can do various task
Let's say I want make some of my sources publicly available via my blog
I am new android app developer i want make app for tablets and phone
I have style sheet with a class name changebackgroundcolor i want make change in

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.