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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:56:50+00:00 2026-05-19T12:56:50+00:00

I have a dynamically generated list of URL’s from our internal network. For each

  • 0

I have a dynamically generated list of URL’s from our internal network. For each URL, I want to:

  1. Find the IP of the URL.
  2. Compare the IP to a list of IP’s and their associated server.
  3. Return the server associated with the IP.

The IP of course is UNIQUE in the list of IP’s, so is there a recommended way to initially store the list of IP values so I can supply it with a an IP (key) and get back the associated server (value)?

I’ve looked at multidimensional arrays, or even brute force — just create an array for each individual server’s IP list — but that seems inefficient.

Here is the PHP I want to have (psuedo):

$IPServerList = array(0 => array(ip=>1.2.3.4,server=>"server1"),
       1 => array(ip=>2.1.3.4,server=>"server2"),
       2 => array(ip=>3.1.3.3,server=>"server1"));

getServer("url1.mycoolurl.com");

function getServer($url) {
    $ip = gethostbyname($url);
"Search $IPServerList for this $ip and return the 'server' value"
    // 

}

Are there any specific ways I should be storing the IP/Server list? Any recommended built in PHP functions to do the search? Any help is appreciated!

  • 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-19T12:56:51+00:00Added an answer on May 19, 2026 at 12:56 pm

    I’m not seeing any obvious reason for avoiding associative arrays:

    $IPServerList = array(
      '1.2.3.4' => "server1",
      '2.1.3.4' => "server2",
      '3.1.3.3' => "server1",
    );
    

    Arrays in PHP double has hashs/maps/dictionaries, depending on what you’re used to calling them. The point is, you can use any unique string/number for your array index, and since you seem to have a 1-to-1 mapping of IPs to server names, this seems ideal.

    I don’t think you’re likely going to find a faster way in PHP to access your data, and you can’t beat it for simplicity:

     if (array_key_exists($IPServerList, '192.168.1.1')) {
       echo $IPServerList['192.168.1.1'];
     }
    

    The PHP manual on arrays will be useful.

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

Sidebar

Related Questions

I have a page that contains dynamically generated Dropdown List controls and I want
I have a list of dynamically generated div-tags with a class-attribute but no id.
For my palm pre app I have a dynamically generated list (pulling in data
I have a drop down list that is dynamically generated using a mySQL database
I have a list of pages that are dynamically generated with a echo statment.
I have a Html Table which consists of rows that were generated dynamically (from
i have a table array dynamically generated from a data query and stored in
I have a form that is dynamically generated, and has dynamically generated id's (and
At the moment I have a set of divs, generated dynamically by php and
I have some dynamically created inputs which are not server-side controls. I want to

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.