return all content types name containing text files I want to get the content type name instead of the file name:
I have this function that access to the files folder: site/all/default/files and get all the file with a text extension and put the text files in an array, is there a possibilty to retun all content types names that contain text files instead of the text files names?

function get_projects(){

$directory= variable_get('file_directory_path', 'sites/default/files');
$filenames = array();
$extension =".txt";

$iterator = new DirectoryIterator($directory);
foreach ($iterator as $fileinfo) {
if ($fileinfo-&gt;isFile()) {
    //check the extension ".txt"
    if (strpos($fileinfo-&gt;getFilename(),'.txt') !== false)
    {
        //Delete the extension ".txt"
        $filenames[$fileinfo-&gt;getMTime()] =substr($fileinfo-&gt;getFilename(), 0, -4);
        //$filenames[$fileinfo-&gt;getMTime()] =$fileinfo-&gt;getFilename();
        //$fileinfo-&gt;getFilename().get
     }
 }
}
 return $filenames;

}
function get_content_type_by_filename($filenames = array()) {
    $sql = "SELECT nt.name, fm.fid
    FROM file_managed AS fm
    LEFT OUTER JOIN file_usage AS fu ON (fm.fid = fu.fid)
    LEFT OUTER JOIN node AS n ON (fu.id = n.nid)
    LEFT OUTER JOIN node_type AS nt ON (n.type = nt.type)
    WHERE fu.type = 'node' AND n.nid IS NOT NULL AND fm.filename IN (:filename)";
    $results = db_query($sql, array(':filename' =&gt; $filenames));
    $results = $results-&gt;fetchAll();
    return $results;
  }


This function accepts an array of file names you want to find content types for and returns an array of matched objects with properties fid and content type.

Update:

Please take a note that I am not trying to give you the exact code rather point you in the right direction.

To achieve what you want, call the function you mentioned in the question (i assume it does what you say, that it returns an array of file names)

so :

function get_content_type_by_filename($filenames = array()) {
    $sql = "SELECT nt.name, fm.fid
    FROM file_managed AS fm
    LEFT OUTER JOIN file_usage AS fu ON (fm.fid = fu.fid)
    LEFT OUTER JOIN node AS n ON (fu.id = n.nid)
    LEFT OUTER JOIN node_type AS nt ON (n.type = nt.type)
    WHERE fu.type = 'node' AND n.nid IS NOT NULL AND fm.filename IN (:filename)";
    $results = db_query($sql, array(':filename' =&gt; $filenames));
    $results = $results-&gt;fetchAll();
    $types_array = array();
    foreach($results as $obj) {
      $types_array[] = $obj-&gt;name;
    }
    return $types_array;
  }
$files_array = get_projects();
$content_types_array = get_content_type_by_filename($files_array);


The $content_types_array will contain the array of content type names.
Hope this helps.If this does not give please debug by installing devel module and passing the variables and arrays through dpm() function to see contents of the array.