The source of the memory problem was a infinite loop, caused by my nubness when it comes to PHP string syntax ( clarified here:
https://vborg.vbsupport.ru/showthrea...42#post1440242 ), and that the || should have been a && to prevent the infinite loop.
It still doesn't work (of course), I'm getting impossible results, thats my problem though.
Thanks for the suggestion cheesegrits, I'll look into the xDebug thing.