Usable in both PHP5 and PHP7

Did you try these two proposed solution *one is remmed out):

Edit:
Please explain why your code “doesn’t work correctly”…

…also and far more importantly the supplied code produces syntax errors which should be searched and rectifed before posting.