TXT parsen
bearbeitet von
Hi,
> An strpos habe ich auch gedacht aber ich brauche eine Funktion, die mir alle vorkommen eines Zeichens zurückgibt.
Wenn die Datei immer so aufgebaut ist, kannst du wie erwähnt Regex z.B. mit [`preg_split`](http://php.net/manual/de/function.preg-split.php) verwenden.
[`$res = preg_split('/\R+(?=To:)/m', $txt_file, -1, PREG_SPLIT_NO_EMPTY);`](https://eval.in/608650)
~~~
\R+ matches any Unicode newline sequence; can be modified using verbs
Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
(?=To:) Positive Lookahead - Assert that the regex below can be matched
To: matches the characters To: literally (case sensitive)
m modifier: multi-line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
~~~
lG, Robert