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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:34:14+00:00 2026-05-31T21:34:14+00:00

I have an array which contains sets of three similar named items; however, sometimes

  • 0

I have an array which contains sets of three similar named items; however, sometimes there’s only two items in a set and I want to call these out.

<?php
$items = array(
'reviewpitfighter-1.138x88.jpg',
'reviewpitfighter-2.138x88.jpg',
'reviewpopfulmailsegacd-1.138x92.jpg',
'reviewpopfulmailsegacd-2.138x76.jpg',
'reviewpopfulmailsegacd-3.138x97.jpg'
);
?>

You’ll note that there are two reviewpitfigher* items, and three reviewpopfulmailsegacd* items. I’ve started down a rabbit hole of loops and feel that there is something simple I’m just glossing over.

  • 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-31T21:34:15+00:00Added an answer on May 31, 2026 at 9:34 pm

    Here’s the solution I came up with, sorry it took so long to post.

    foreach($images as $value){
        $lastItem = explode('-', $images[$count - 1]);
        $parts = explode('-', $value);
        if(preg_match('/^1/', $parts[1]) && $count != 0){
            if(preg_match('/^2/',$lastItem[1])){
                $imgurl = preg_replace('/^p?review/','',$lastItem[0]);
                $sql = 'SELECT field FROM table WHERE field = "' . $imgurl . '"';
                $result = $dbConn->FetchArray($dbConn->Query($sql), MYSQL_ASSOC);
                $array[$imgurl] = $result;
            }
        }
        $count++;
    }
    

    I get an array of all the images, then I check to see if I’m looking at the first image, if I am then I see if the last image I looked at was the second image. At this point I then call into the database to get some information to display a neatly messaged out put of what reviews are missing a third image. In the end $array contains this list which I can loop over.

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

Sidebar

Related Questions

I have an array which contains serialized data similar to the example below. Array
I have an array which contains 2 types of items (lets call them type
I have a array called $A which contains only non zero positive numbers. Now
I have two arrays, the first one is a (n, 2) array which contains
I have a 2D array which just contains boolean values showing if there is
i have a (dynamic) array, which in this example contains 4 sets of data
I have an array which contains an number of array objects. Is there a
I have an array which contains a set of information from a database, but
i have an array which contains only 2 types of numbers(x and x-1) eg:-
I have an array which contains items of NSDictionary , I want to transform

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.