I am using str_replace to remove certain string that starts with the '#' character from a read txt file, however the html output when tested removes only the # symbol. The problem I am having is that I want to remove all of the text beginning with that particular character (including '#' too).
So far I have tried:
1)
$data = str_replace('#','',file_get_contents($strFileName));
return $data;
2)
fopen($strFileName,'r');
$remove = "#";
$tmpData = file_get_contents($strFileName);
$data = preg_replace("/.*\b" . $remove ."\b.*\n/ui", "#" , $tmpData);
return $data;
The original text file is like this:
#
# bla bla bla
#
# bla bla bla
#
# bla bla bla
The first try did remove the #
character but left the rest of the words.
The second didn't work at all.
Thanks.