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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:41:59+00:00 2026-06-01T10:41:59+00:00

I would like to see the best way to create a where statement with

  • 0

I would like to see the best way to create a where statement with a PHP array

$array = array (
  0 => array (
    'host' => 'aol.com',
    'type' => 'A',
    'ip' => '64.12.89.186',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  1 => array (
    'host' => 'aol.com',
    'type' => 'A',
    'ip' => '205.188.100.58',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  2 => array (
    'host' => 'aol.com',
    'type' => 'A',
    'ip' => '205.188.101.58',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  3 => array (
    'host' => 'aol.com',
    'type' => 'A',
    'ip' => '207.200.74.38',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  4 => array (
    'host' => 'aol.com',
    'type' => 'A',
    'ip' => '64.12.79.57',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  5 => array (
    'host' => 'aol.com',
    'type' => 'NS',
    'target' => 'dns-01.ns.aol.com',
    'class' => 'IN',
    'ttl' => '2466'
  ),
    '6' => 'array (',
    'host' => 'aol.com',
    'type' => 'NS',
    'target' => 'dns-07.ns.aol.com',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  7 => array (
    'host' => 'aol.com',
    'type' => 'NS',
    'target' => 'dns-06.ns.aol.com',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  8 => array (
    'host' => 'aol.com',
    'type' => 'NS',
    'target' => 'dns-02.ns.aol.com',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  9 => array (
    'host' => 'aol.com',
    'type' => 'SOA',
    'mname' => 'dtc-ext3.edns.aol.com',
    'rname' => 'hostmaster.aol.net',
    'serial' => '352455322',
    'refresh' => '43200',
    'retry' => '180',
    'expire' => '2592000',
    'minimum-ttl' => '300',
    'class' => 'IN',
    'ttl' => '1691'
  ),
  10 => array (
    'host' => 'aol.com',
    'type' => 'MX',
    'pri' => '15',
    'target' => 'mailin-04.mx.aol.com',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  11 => array (
    'host' => 'aol.com',
    'type' => 'MX',
    'pri' => '15',
    'target' => 'mailin-01.mx.aol.com',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  12 => array (
    'host' => 'aol.com',
    'type' => 'MX',
    'pri' => '15',
    'target' => 'mailin-02.mx.aol.com',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  13 => array (
    'host' => 'aol.com',
    'type' => 'MX',
    'pri' => '15',
    'target' => 'mailin-03.mx.aol.com',
    'class' => 'IN',
    'ttl' => '2466'
  ),
  14 => array (
    'host' => 'aol.com',
    'type' => 'TXT',
    'txt' => 'v=spf1 ptr:mx.aol.com ?all',
    'class' => 'IN',
    'ttl' => '2465'
  ),
  15 => array (
    'host' => 'aol.com',
    'type' => 'TXT',
    'txt' => 'spf2.0/pra ptr:mx.aol.com ?all',
    'class' => 'IN',
    'ttl' => '2465'
  )
);

This is my Array I would like to make a where statement for on EX type = NS and so on then pass all that in to a variable to be displayed.

Please note if I do not respond to comment/questions, I will with in the next few hours my internet will be going down for repair.

  • 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-01T10:42:00+00:00Added an answer on June 1, 2026 at 10:42 am

    Are you using dns_get_record? If so, the second parameter restricts the type of record returned, so you could use DNS_NS to filter your example. Otherwise use array_filter:

    $wantedType = 'NS';
    
    var_dump(array_filter($records, function($record) use ($wantedType) {
        return ($record['type'] === $wantedType);
    }));
    

    You could generalise this even more:

    // expand as necessary
    $requirements = array(
        'type' => 'NS',
    );
    
    var_dump(array_filter($records, function($record) use ($requirements) {
        // only include if all the requirements match
        return (array_intersect($requirements, $record) == $requirements);
    }));
    

    Or to group by type:

    $groupedRecords = array();
    
    foreach ($records as $record) {
        if (!array_key_exists($record['type'], $groupedRecords)) {
            $groupedRecords[$record['type']] = array();
        }
    
        $groupedRecords[$record['type']][] = $record;
    }
    
    // $groupedRecords now contains all records nested by record type
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to see best way of posting to Facebook from a HTML
I would like to see if an object is a builtin data type in
What would be the best way to create unit tests for testing the parameters
I would like to see how this example of existing code would be able
I would like to see how a program responds when it's connection is severed.
I would like to see if a value equals any of the values in
I would like to see all revision numbers that made any changes to a
I have a Windows Service and I would like to see what it's doing
This is a follow-up question to the following if you would like to see:
I've just discovered Sikuli , and would like to see a comprehensive functions list

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.