hi,
i use php for searching keyword in word document.but it more time to get a output how will reduce the execution time..
i use php for searching keyword in word document.but it more time to get a output how will reduce the execution time..
Code:
if($open=opendir($namedir))
{
while($filedir=readdir($open))
{
if($filedir!="." && $filedir!="..")
{
$name=$namedir."/".$filedir;
//$handle=fopen("$filedir","r");
$filedata=file_get_contents($name);
for($count=0;$count<count($arraykey);$count++)
{
if(preg_match("/\b$arraykey[$count]\b/i","$filedata"))
{
$match[]="true";
}
else
{
$match[]="flase";
}
}
if(($andkey=="and") and ($orkey=="or"))
{
for($countno=0;$countno<count($arraykey);$countno++)
{
if($key[$countno]=="and")
{
$andval++;
if($match[$countno]=="true")
{
$value++;
}
}
else if($key[$countno]=="or")
{
if($match[$countno]=="true")
{
$valueno++;
}
}
}
if($andval==$value and $valueno > 1)
{
$flag="ok";
}
else
{
$flag="not";
}
}
else if(($andkey=="and") and ($orkey==NULL))
{
for($countno=0;$countno<count($arraykey);$countno++)
{
if($match[$countno]=="true")
{
$value++;
}
}
if(count($arraykey)==$value )
{
$flag="ok";
}
else
{
$flag="not";
}
}
else if(($orkey=="or") and ($andkey==NULL))
{
for($countno=0;$countno<count($arraykey);$countno++)
{
if($match[$countno]=="true")
{
$value++;
}
}
if($value >= 1)
{
$flag="ok";
}
else
{
$flag="not";
}
}
else if($andkey==NULL and $orkey==NULL)
{
for($co=0;$co<count($arraykey);$co++)
{
if($match[$co]=="true")
{
$valdata++;
}
}
if(count($arraykey)==$valdata)
{
$flag="ok";
}
else
{
$flag="not";
}
}
if($flag=="ok")
{ $i++;
// echo $filedir."<br>";
print"<input type=\"checkbox\" value=\"$name\" id=\"name$i\" name=\"ss\"><a href=\"#\" id=\"link$i\" onClick=\"fnopen('$name','$aa')\" onDblClick=\"fnword('$name')\">$filedir</a><br>";
}
unset($match,$flag,$vardata,$count,$valueno,$value,$andval,$valdata);
}
Comment