I’m trying to figure how a function I’ve been given works — or rather doesn’t work. The problematic areas include array notation like this:
$small[$end[$i]{0}]
I think the idea is to append “0” to the value of $end[$i] and use that for the index of $small. But it doesn’t work in PHP5.3. Is this a deprecated syntax and is it trying to do what I think it is?
It’s getting the first character from the
$end[$i]string and then accessing the$smallarray using that character as the array key.Edit:
The easiest way is
substr($foo, 0, 1)in PHP.If you’re using a strongly typed language, I have some metrics you may be interested in reading from another answer of mine: How can you get the first digit in an int (C#)?