I know that this question has been asked endless times, but I can’t find a working solution for my case.
I want to split a string in PHP (5.3), using semicolons as separators if they are not between the lines $BODY$. The goal is to break up SQL statements where statements can be procedures (postgresql in this case).
Example:
select; start $ BODY $ begin; end; $ BODY $ lang; update
It should turn out:
select
start $ BODY $ begin; end; $ BODY $ lang
update
I played with for a while preg_splitand did not find a working solution.
Many thanks
Edit: it should work with multi-line inputs (but I can remove line breaks using str_replacebefore starting)
source
share