Hello.

There is a code

$type=array( "фильмы"=>"movie", "сериалы"=>"serial", "музыка"=>"music" ); for($i=0; $i<count($result); $i++){ preg_match_all('|<a href="blabla/[0-9]*)">(.*)</a>|U',$result[$i][3],$category,PREG_SET_ORDER); if($type[$category[0][2]] && !empty($category[0][1])) // найдено } 

How can you check the presence of the value of $category (in the loop, each can have several values) in the array $type ? The problem is that in $category (taken with the help of preg_match_all ) there can be several values.

    1 answer 1

    To check if a value exists in an array, you need to apply one of these functions:

     bool in_array ( mixed needle, array haystack [, bool strict] ) 

    Example:

     <?php $os = array("Mac", "NT", "Irix", "Linux"); if (in_array("Irix", $os)) { echo "Got Irix"; } if (in_array("mac", $os)) { echo "Got mac"; } ?> 

    Analog:

     mixed array_search ( mixed needle, array haystack [, bool strict] )