Q:

multi dimensional array keys returning single characters, not values

I see this problem on and off again in my PHP coding, and I've never understood what's happening.
$val = $matches[1][$i]

In this example, $i = 0 (set in a for loop) and the value held in that dimension of the array is a string. Instead of that string being assigned to $val, $val gets assigned the 0th (first) character in the string. If $i = 1, $val gets assigned the 1st (second) character in the string, etc.
Instead of returning the string, why is PHP treating this like a substring operation? How can I get my string value instead of a single character in that string?

A:

Are you sure it's a multidimensional array? I think that if you access a string like an array it returns the character at the key's position in the string, and that could be your problem. Check your assignments and whatnot and make sure you're not accidentally assigning a string to $matches[1] instead of an array of strings.

