如何检查多维数组中的双字段?

时间:2011-07-15 15:11:32

标签: php

如何检查多维数组中的双字段?

我的阵列:

    array (
  'welcome' => 
  array (
    0 => 
    array (
      'url' => '/strona-powitalna',
      'component' => 'welcome',
      'action' => 'getForumPosts',
      'parameter' => 
      array (
        0 => 
        array (
          'name' => '',
          'type' => '',
          'default' => '',
          'method' => '',
        ),
      ),
      'parameters_all' => '1',
      'parameters_get' => 0,
      'parameters_post' => 0,
    ),
  ),
  'logi' => 
  array (
  ),
  'main' => 
  array (
    0 => 
    array (
      'url' => '/refresh',
      'component' => 'main',
      'action' => 'refreshPlayer',
      'contype' => 'AJAX',
      'parameter' => 
      array (
        0 => 
        array (
          'name' => '',
          'type' => '',
          'default' => '',
          'method' => '',
        ),
      ),
      'parameters_all' => '1',
      'parameters_get' => 0,
      'parameters_post' => 0,
    ),
  ),
  'account' => 
  array (
    0 => 
    array (
      'url' => '/zmien-kolor',
      'component' => 'account',
      'action' => 'changeColorName',
      'contype' => 'COMMON',
      'parameter' => 
      array (
        0 => 
        array (
          'name' => 'rgb',
          'type' => 'string',
          'default' => '',
          'method' => 'POST',
        ),
      ),
      'parameters_all' => '1',
      'parameters_get' => 0,
      'parameters_post' => 1,
    ),
    1 => 
    array (
      'url' => '/kolor-nicku',
      'component' => 'account',
      'action' => 'colorName',
      'contype' => 'COMMON',
      'parameter' => 
      array (
        0 => 
        array (
          'name' => '',
          'type' => '',
          'default' => '',
          'method' => '',
        ),
      ),
      'parameters_all' => '1',
      'parameters_get' => 0,
      'parameters_post' => 0,
    )));

我必须检查参数url是否唯一。

1 个答案:

答案 0 :(得分:1)

foreach($arrays as $array)
  if(is_array($array)) 
    foreach($array as $key => $data) 
      if(strcmp($key,'url') == 0  && strcmp($key,$url) == 0){
        echo $url.' is not unique url!'; 
        break;
      } 

其中$ url变量是您在数组中寻找的url。