John Magnolia
John Magnolia

Reputation: 16793

Add 2 variables together to make another variable

What am I doing wrong here to get undefined variable notice.

if (isset(${$error_description_.$i}[$lang])) {

Previously I had this:

if (isset($error_description_1[$lang])) {

I now have this inside a for loop where 1 is replaced.

Upvotes: 1

Views: 61

Answers (2)

Andres Orav
Andres Orav

Reputation: 61

This should work:

if (isset(${'error_description_' . $i}[$lang])) {
}

Upvotes: 0

Sharanya Dutta
Sharanya Dutta

Reputation: 4021

It should be:

if (isset(${"error_description_".$i}[$lang])) {

Upvotes: 2

Related Questions