This question might be a duplicate of why in array single quotes not required according to the syntax
but I didn't the explanation I need over there. We know we can do echo "$myArr[0]"
, but we can't do the same with associative arrays like echo "myAssocArr['myKey']"
. I know we can use php complex syntax to get around, like echo "{myAssocArr['myKey']}"
.
My question is, if php can access normal index arrays without complex syntax, then why can't it access accosiative arrays' values as well. What is happening inside php compiler/zend/whatever engine that prevents it from accessing assosiative arrays' values in a string without the complex syntax.
source https://stackoverflow.com/questions/70137461/why-does-php-need-complexcurly-syntax-to-parse-associative-array-values-in-a-s
Comments
Post a Comment