function dataRet($word) { $file = 'somefile.txt'; $read = fopen($file, "r"); while (!feof($read)) { $info = explode(" ", fread($read, filesize($file)),2); if ($info[0] == $word) { return $info[1]; } } fclose($read); return 'No data found.'; }