How efficient is PHP's substr?
Posted
by zildjohn01
on Stack Overflow
See other posts from Stack Overflow
or by zildjohn01
Published on 2010-05-11T17:51:30Z
Indexed on
2010/05/11
18:14 UTC
Read the original article
Hit count: 304
I'm writing a parser in PHP which must be able to handle large in-memory strings, so this is a somewhat important issue. (ie, please don't "premature optimize" flame me, please)
How does the substr
function work? Does it make a second copy of the string data in memory, or does it reference the original? Should I worry about calling, for example, $str = substr($str, 1);
in a loop?
© Stack Overflow or respective owner