I've got the following text :
NOTEU START
#Line1 #
#Line2 #
#Line3 #
#Line4 #
NOTEU END
I explode the text at every pound sign:
$noteText = explode("#", $message);
Producing an array :
( [0] => [1] => Line1 [2] => [3] => Line2 [4] => [5] => Line3 [6] => [7] => Line4 [8] => )
I get empty elements in the array which represent the spaces between two consecutive pound signs.
My end goal is to split each line (text inside pound signs) into an array.
This can be achieved by removing these empty array elements however I can't seem to remove them, I've tried :
print_r(array_filter($noteText));
foreach($noteText as $key => $val) {
if ($val == "") unset($noteText[$key]);
}
Which has no effect on removing these empty spaces.
preg_match_all("/#(?P<lines>.*)#/", $input, $result);seems to give the right result (in$result['lines'])) for your input...