Location: PHPKode > projects > Taxonomic Search Engine > agrep.php
<?php

/* $Id: agrep.php,v 1.1.1.1 2005/05/19 10:31:10 rdmpage Exp $ */

/**
 * @file agrep.php
 *
 * @brief Wrapper around agrep
 *
 */

/*
*@brief Wrapper for agrep approximate string matching program
 *
 * Function returns the
 * @param $agrep_pattern pattern to search for
 * @param $agrep_file file to search for pattern
 * @param $agrep_matches stores array of strings that match pattern
  * @param $agrep_options command line options for agrep (optional, default is -x [match whole words])
 * @param $agrep_mismatch number of mismatches allowed (optional, default is 2)
 */
function agrep($agrep_file, $agrep_pattern, &$agrep_matches, $agrep_options="-x", $agrep_mismatch = 2)
{
	$agrep_path = "/usr/local/bin/agrep";	// path to agrep
	$agrep_command = "$agrep_path -$agrep_mismatch $agrep_options '$agrep_pattern' $agrep_file";

	//echo $agrep_command;
	exec ($agrep_command, $agrep_result);

	$agrep_matches = $agrep_result;
	return sizeof($agrep_result);
}

//	$name = "Apusi";
//	$num_matches = agrep ('namelist.txt', $name, $agrep_match);

//	echo $num_matches;

//	print_r ($agrep_match);



?>
Return current item: Taxonomic Search Engine