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?
To further Chad’s comment, your code would require both strings (the full one, and the full-one-minus-first-character) to be in memory at the same time (though not due to the assignment as Chad stated). See:
Outputs something like (memory values are in bytes):