if ( array_search(array('forum_cat_id' => '100'), $cache_forums) ) {
         echo 'found';
return true;
} else {
         echo 'not found ';
return false;
}
--------------------------------
衷心预祝孙燕姿大陆演唱会成功!!

解决方案 »

  1.   

    谢谢了,我测试通过,可是当数组是下面这样的时候,程序该什么写呢?
    $cache_forums = array
            (
            1 => array
                     (
                      'forum' => 'YYY'
                      'forum_name' => 'fff'
    'forum_cat_id' => '144'
                     ),
            2 => array
                     (
                      'forum' => 'YYY'
                      'forum_name' => 'g'
    'forum_cat_id' => '12'
                     ),
            3 => array
                     (
                      'forum' => 'YYY'
                      'forum_name' => 'YYY'
    'forum_cat_id' => '100'
                     )
            );
      

  2.   

    多维数组请这样,php.net上抄的 ^_^<?php
    function SearchBiDimArray(&$theArray, $dimNo, $searchValue, $returnIndex = true){
       if(is_array($theArray)){
           $keys = array_keys($theArray[0]);
           $key = $keys[$dimNo];
           $elcount = count($theArray);       for($i=0; $i < $elcount; $i++){
               if($theArray[$i][$key] === $searchValue){
                   if ($returnIndex){
                       return $i;
                   }
                   else{
                       return $theArray[$i];
                   }
               }
           }   }
       else{
           return array_search($searchValue, $theArray);
       }
    }$theArray = array();
    $theArray[0]['firstproperty'] = 'avalue1';
    $theArray[0]['secondproperty'] = 'anothervalue1';$theArray[1]['firstproperty'] = 'avalue2';
    $theArray[1]['secondproperty'] = 'anothervalue2';$theArray[2]['firstproperty'] = 'avalue3';
    $theArray[2]['secondproperty'] = 'anothervalue3';print SearchBiDimArray($theArray, 1, 'anothervalue2', true);
    // result is 1print SearchBiDimArray($theArray, 1, 'anothervalue2', true);
    // result is
    //Array
    //(
    //    [firstproperty] => avalue2
    //    [secondproperty] => anothervalue2
    //)?> 
      

  3.   

    类推就行了
    if ( array_search(array('forum' => 'YYY', 'forum_name' => 'YYY', 'forum_cat_id' => '100'), $cache_forums) ) {
             echo 'found';
         return true;
    } else {
             echo 'not found ';
         return false;
    }