PHP数组搜索文件类型并查看文件是否存在

<?php
$rn = $_GET['rn'];

$file_exts = array("jpg", "jpeg", "png");
$upload_exts = end(explode(".", $rn));

#$images/$rn

if (in_array($upload_exts, $file_exts)) {

  #if (in_array(file_exists($haystack), $needle) {
  if (array_search($upload_exts, $file_exts/*file_exists("c:/xampp\htdocs\php/images/" .*/)) {
     $str_img = str_replace(' ', '_', $rn);
  } else {
     $str_img = 'thumb.png';
  }
}

echo $str_img;
?>

Okay so I have this code, but I can't get the result I'm looking for.
I want to see if a file exist, using array_* and other functions like file_exists.
What my problem is, when I want to add a new file type, I will just type it in the array field, and it will search for it, if an image/file was found, the file name + file type will be printed out e.g google-img.jpg, else it whould print thumb.png.

Use file_exists with dirname(__ FILE __):

$rn = $_GET['rn'];
$file_exts = array("jpg", "jpeg", "png");
$upload_exts = end(explode(".", $rn));

function exists( $file ) {
$file_exts = array("jpg", "jpeg", "png");
$upload_exts = end(explode(".", $file));
 if( in_array($upload_exts, $file_exts) && file_exists( dirname(__FILE__) . '/' . $file ) )
  return $file;
 foreach($file_exts as $a)
 if( file_exists( dirname(__FILE__) . '/' . $file . '.' . $a) )
  return $file.'.'.$a;
 return false;
 }
 if( exists($_GET['rn']) )
   $str_img = str_replace(" ", "_", exists($_GET['rn']));
 else
   $str_img = 'thumb.png';
echo $str_img;