function create_tmp_file($data) { $tmp_file = tmpfile(); fwrite($tmp_file, $data); rewind($tmp_file); return $tmp_file; }