Is there a faster way to return values of an array that are not not in another array

Discussion in 'PHP' started by meroving, May 13, 2010.

  1. #1
    Is there a faster way to do this? It is pretty slow when you are checking lots of data
    
    $dataArray = array(0=>4, 1=>5, 2=>6, 3=>7, 4=>8);
    $checkArray = array(0=>4, 1=>5, 2=>6);
    
    foreach($dataArray as $data){
    	if(!in_array($data, $checkArray)){
    		$returnData[] = $data;
    	}
    }
    
    print_r($returnData);
    
    PHP:

     
    meroving, May 13, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    danx10, May 13, 2010 IP
  3. meroving

    meroving Peon

    Messages:
    135
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks man!
     
    meroving, May 13, 2010 IP