Multidimensional array keys returning single characters rather than values
I see this problem over and over in my PHP coding and I never really understood what was going on.
$val = $matches[1][$i]
In this example, $ i = 0 (set in the for loop), and the value contained in this dimension of the array is a string. Instead of this string being assigned to $ val, $ val gets the 0th (first) character in the string. If $ i = 1, $ val gets the 1st (second) character in the string, etc.
Instead of returning a string, why does PHP treat this as a substring operation? How can I get my string value instead of one character in this string?
a source to share
Are you sure this is a multidimensional array? I think that if you access a string like an array, it returns the character at the key position of the string and that might be your problem. Check your assignments and more and make sure you don't accidentally assign the string $ matches [1] instead of an array of strings.
a source to share