3 ms·
That is what I would call "not so much". PHP is inherently ugly but this is just excessive. Temporary variables, needless loops, off by one logic errors compens
by shaunxcode 17y ago
That is what I would call "not so much". PHP is inherently ugly but this is just excessive. Temporary variables, needless loops, off by one logic errors compensated for with extra substr call. yuck. How about:
return join($delim, array_reverse(split($delim, $str)));
Or more ideally with a little fluidity, assuming a string object:
return $str->split($delim)->reverse()->join($delim);