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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:07:33+00:00 2026-06-10T01:07:33+00:00

I have two arrays built from an XML response to an api. One array

  • 0

I have two arrays built from an XML response to an api. One array gives me the product info form one store and the other array gives me just the stock level in another. It looks like this:

foreach($filteredStock as $t=>$k){
    $codeFirst[] = $k['code'];

    echo '<tr><td>'.$t;
    echo '</td><td>'.$k['desc'];
    echo '</td><td>'.$k['family'];
    echo '</td><td>'.$_POST['filterSelect'];
    echo '</td><td>'.$k['onOrder'];
    echo '</td><td>'.$k['cost'];
    echo '</td><td>'.$k['sell'];
    echo '</td><td>'.$k['invStore'];
    echo '</td>';
}

$output = array();

$result = array_intersect_key($mainArray, array_flip($codeFirst));
foreach($result as $results=>$rValues){

    echo '<td>'.$rValues['inv'];
    echo '</td>'; 
    echo '</tr>';
}

I want to display it so that it looks like this in the table:

code / desc / family / filteredClass / onOrder / cost / sell / invStore / invwarehouse

Because I need the second foreach loop to grab the values of the second array it causes a problem trying to get it to repeat on each line with the other array. Any suggestions?

  • 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-10T01:07:35+00:00Added an answer on June 10, 2026 at 1:07 am

    Rather than echoing output each time the loop iterates, why don’t you build up the table how you want it and then output it when you have it arranged properly?

    It’s not clear to me from the code exactly what you are trying to do, but if it’s an organisation problem then why don’t you store the values in seperate arrays and then combine then and arrange them appropriately before outputting them?

    Using echo immediately for each loop iteration limits your options somewhat.

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

Sidebar

Related Questions

I have built a custom hashmap using two arrays. One contains keys another values.
I have two arrays. I'd like to copy ranges of data from one of
If I have two byte[] arrays, is there a built-in function to compare them
I have two arrays and I post the arrays in one input; <input name='sistem[]'
I have two arrays, the first one contents numbers and the second one use
I have two arrays... $Name = array(a, b, c, d); $Value = array(1, 2,
I'm using php with smarty. In php I have two arrays: $code = Array
I have two arrays: Parents: Array ( [0] => Levi Self [2] => Portraits
I have two arrays built while parsing a text file. The first contains the
I have two PHP arrays. One contains a group name and another contains a

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.