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

  • Home
  • SEARCH
  • 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 6747537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:27:22+00:00 2026-05-26T12:27:22+00:00

I have an array like this Array ( [0] => Array ( [0] =>

  • 0

I have an array like this

Array
(
    [0] => Array
        (
            [0] => 83
            [1] => 82
            [2] => 81
        )

    [1] => Array
        (
            [0] => 81
            [1] => 82
            [2] => 83
            [3] => 100
            [4] => 101
            [5] => 102
            [6] => 103
            [7] => 104
            [8] => 105
        )

)

and I want to delete any values from the first array that are not equal to this array

Array
(
    [0] => 83
    [1] => 82
    [2] => 81
)

But i want to keep the same structure as the first array. So i would end up with something like this

Array
(
    [0] => Array
        (
            [0] => 83
            [1] => 82
            [2] => 81
        )

    [1] => Array
        (
            [0] => 81
            [1] => 82
            [2] => 83
        )

)

What is the best way to achieve this?

  • 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-26T12:27:23+00:00Added an answer on May 26, 2026 at 12:27 pm

    if $array is your starting array and $matches is the array of values you want to match;

    foreach ($array as $key => $subarray) {
        foreach ($subarray as $subsubarray) {
            foreach ($matches as $match) {
                if ($subsubarray == $match) {
                    $finalarr[$key][] = $subsubarray;
                }
            }
        }
    }
    

    $finalarr will be your desired result.

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

Sidebar

Related Questions

i have a list like this: array( array(id=>100, parentid=>0, name=>'a'), array(id=>101, parentid=>100, name=>'a'), array(id=>102,
i have 9 progress bars. generated from an array like this: $progress = 100-30-0-0-0-0-0-0-0;
In PHP I have an array that looks like this: $array[0]['width'] = '100'; $array[0]['height']
I have an array like this: int a[100]; I am filling only the first
I have something like this: long[] f = new long[4]{1,10,100,1000}; I want to divide
I'm pulling a content from PHP array and I have a situation like this:
I have an array like this: $a = array( array('amount'=>10,'curr'=>'USD'), array('amount'=>20,'curr'=>'JPY'), array('amount'=>30,'curr'=>'BAT'), array('amount'=>50,'curr'=>'BAT'), array('amount'=>100,'curr'=>'USD')
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have an array like this: object[] args and need to insert those args
I have an array like this: $sports = array( 'Softball - Counties', 'Softball -

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.