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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:15:32+00:00 2026-06-16T02:15:32+00:00

I have the follow foreach loop: <?php $arrayforward = get_field(‘background_slider’); $arrayreversed = array_reverse($arrayforward); $count=1;

  • 0

I have the follow foreach loop:

<?php $arrayforward = get_field('background_slider');
        $arrayreversed = array_reverse($arrayforward);
        $count=1;

        foreach($arrayreversed as $subarray) {

        $subfield1 = $subarray['background_image'];
        $subfield2 = $subarray['background_image_alt'];
        $subfield3 = $subarray['text_image'];
        $subfield4 = $subarray['text_image_alt']; ?>

        <div id="slide<?php echo $count; ?>" class="contentslider_wrapper">
            <div class="fullpageimage">
                <img id="slideImg<?php echo $count; ?>" src="<?php echo $subfield1; ?>" alt="<?php the_sub_field('background_image_alt'); ?>" />
                <img id="textImg<?php echo $count; ?>" class="slidetext" src="<?php echo $subfield2; ?>" alt="<?php the_sub_field('text_image_alt'); ?>" />
            </div>
        </div>

        <?php $count++; }; ?>

I need help getting the count to reverse. The output I am looking for is as follows:

<div id="slide4"></div>
<div id="slide3"></div>
<div id="slide2"></div>
<div id="slide1"></div>

Any help with this would be great.

  • 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-16T02:15:35+00:00Added an answer on June 16, 2026 at 2:15 am

    First of all get the amount of keys in the array and assign it as $count, like this:

    $count = count($arrayreversed);
    

    Then replace the $count++ with $count-- and you’re all set.

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

Sidebar

Related Questions

So I have a php foreach loop as follows, $i = 1; foreach($rows as
I have a PHP while loop as follow: <?php while (have_posts()) : the_post(); ?>
I have a foreach loop which echo 's each of the property types in
I have a foreach loop that cycles through a list of types and creates
I have a foreach loop that iterates over objects in an array. Currently, it
I have a PHP for loop: for ($counter=0,$counter<=67,$counter++){ echo $counter; $check=some value; } What
I have select values as follows: <select id=SelectBox multiple=multiple> <% foreach (var item in
i have follow taxomony has been set up: accommodation -backpacker -guest -holiday and i
I have this follow code in my javascript. I call this function when the
I have the follow query: SELECT pro.* FROM tb_AutProposta pro, tb_AutParcelamento par WHERE pro.id

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.