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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:29:33+00:00 2026-05-25T02:29:33+00:00

The [sample] code below seems like it could be better in a loop or

  • 0

The [sample] code below seems like it could be better in a loop or something to make it more dynamic. The only thing that changes is the _xx and _xxyy in the field/variable name. How can I improve this so I don’t have to write 20 if statements?:

    <?php if (get_custom_field('itinerary_title_02')):?>
    <div id="itinerary_entry">
        <h2><?php print_custom_field('itinerary_title_02'); ?></h2>
        <p><?php print_custom_field('itinerary_content_02'); ?></p>
        <p class="accommodation_name"><?php print_custom_field('itinerary_acc_nme_02'); ?></p>
        <p class="accommodation_desc"><?php print_custom_field('itinerary_acc_dsc_02'); ?></p>
        <?php if (get_custom_field('itinerary_photo_0201')):?>
        <div><img src="<?php print_custom_field('itinerary_photo_0201'); ?>"></div>
        <?php endif;?>
    </div>
    <?php endif;?>

    <?php if (get_custom_field('itinerary_title_03')):?>
    <div id="itinerary_entry">
        <h2><?php print_custom_field('itinerary_title_03'); ?></h2>
        <p><?php print_custom_field('itinerary_content_03'); ?></p>
        <p class="accommodation_name"><?php print_custom_field('itinerary_acc_nme_03'); ?></p>
        <p class="accommodation_desc"><?php print_custom_field('itinerary_acc_dsc_03'); ?></p>
        <?php if (get_custom_field('itinerary_photo_0301')):?>
        <div><img src="<?php print_custom_field('itinerary_photo_0301'); ?>"></div>
        <?php endif;?>
    </div>
    <?php endif;?>

    <?php if (get_custom_field('itinerary_title_04')):?>
    <div id="itinerary_entry">
        <h2><?php print_custom_field('itinerary_title_04'); ?></h2>
        <p><?php print_custom_field('itinerary_content_04'); ?></p>
        <p class="accommodation_name"><?php print_custom_field('itinerary_acc_nme_04'); ?></p>
        <p class="accommodation_desc"><?php print_custom_field('itinerary_acc_dsc_04'); ?></p>
        <?php if (get_custom_field('itinerary_photo_0401')):?>
        <div><img src="<?php print_custom_field('itinerary_photo_0401'); ?>"></div>
        <?php endif;?>
    </div>
    <?php endif;?>

Thanks in advance!

  • 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-25T02:29:33+00:00Added an answer on May 25, 2026 at 2:29 am
    <?php
    for($i=2 ; $i<5 ; $i++ ){
        $titleNum = sprintf("%02d", $i);
        if (get_custom_field('itinerary_title_'.$titleNum)) {
    ?>
         <div id="itinerary_entry">
             <h2><?php print_custom_field('itinerary_title_'.$titleNum); ?></h2>
             <p><?php print_custom_field('itinerary_content_'.$titleNum); ?></p>
             <p class="accommodation_name"><?php print_custom_field('itinerary_acc_nme_'.$titleNum); ?></p>
             <p class="accommodation_desc"><?php print_custom_field('itinerary_acc_dsc_'.$titleNum); ?></p>
         <?php if (get_custom_field('itinerary_photo_'.$titleNum.'01')){ ?>
             <div><img src="<?php print_custom_field('itinerary_photo_'.$titleNum.'01'); ?>"></div>
         <?php } ?>
         </div> 
         <?php }
         }
         ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a plot (sample code pasted below) that I am trying to add
The code below shows a sample that I've used recently to explain the different
The code below generates a warning CS3006 Overloaded method MyNamespace.Sample.MyMethod(int[])' differing only in ref
The code below is more or less taken from the example MPMoviePlayerController sample code.
I'm trying to do something that seems like it should be very simple, but
In the sample code below I am dividing by zero which when I step
In the below code sample, what does {0:X2} mean? This is from the reflection
I've put together a small code-sample below (Currently in C# 3.5 but would also
Below is sample code to create a radio button element with Yes/No options in
I am using FBConnect on Android, it seems that the only ID I need

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.