Php function for search from a file

If you have the start and end points, you can get the content of that two points. (as a example if the start and end point are and then u can get the content of these tags using this function. eg: content)

“,””,$contents);
$t = my_strip(“abc”,”xyz”,$contents);

echo $t;
?>

aaa.txt
=====
ntbfjkb n jABCjergnv
fvb j njrbn ntbfjkb n jegnb ef
g45yyyXYZtrgjrgbXYZk oi iABCyji oni jij

output
=====
jergnv fvb j njrbn ntbfjkb n jegnb ef g45yyy

Advertisements

sample code for undestand php file handling functions

$comment = $_POST[“txtcomment”];
if ($comment!=””){
$date=date(‘l dS \of F Y h:i:s A’);
$massage = $date.”: “.$comment.”\n”;

$file=fopen(“comment.txt”,”a+”) or exit(“Unable to open file!”);
fwrite($file,$massage) or die(“Could not write to file”);
fclose($file);
echo “Massage sent!”;
}

?>

This will write the massage to the comment.txt file.
%d bloggers like this: