1

我有一个数组:

    array (
     [0] => Array (
         [host] => google.nl
         [class] => IN
         [ttl] => 279310
         [type] => NS
         [target] => ns3.google.com)
     [1] => Array (
         [host] => google.nl
         [class] => IN
         [ttl] => 279310
         [type] => NS
         [target] => ns4.google.com)
     [2] => Array (
         [host] => google.nl
         [class] => IN
         [ttl] => 279310
         [type] => NS
         [target] => ns2.google.com)

这个数组是用dns_get_record ()函数制作的。这是每个域的不同数量的变量。我如何与其他目标进行比较[0]['target'][1]['target']以及[2]['target']是否还有更多目标?

4

1 回答 1

0

我不知道这段代码是用什么语言写的,这是C#\Java中解决这个问题的一个例子,当然还有很多其他的方法。

使用一个简单的for循环,意思是:如果大数组的名字是“mainArray”,你需要做:

foreach (int i=0;i<mainArray.length();i++)
{
  if !(mainArray[i]["target"].Equals(mainArray[i+1]["target"]))
       return false;
}
return true;
于 2013-02-17T21:27:53.820 回答