Variables inside php arrays

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
Forath
New php-forum User
New php-forum User
Posts: 19
Joined: Sat Jun 17, 2017 1:07 pm

Sun Feb 18, 2018 11:22 am

Hi peeps.

I am attempting to recall a value in an array via the key, (straightforward enough, i know,)

I am trying, however, to define the using a variable that is recalled from a sql data set..

eg

Code: Select all

echo $team['. $gotwr[0]['home'].'];
having no success atm

is such a thing possible..

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 757
Joined: Mon Feb 22, 2016 5:52 pm

Sun Feb 18, 2018 11:44 am

Yes it is possible, but you are probably making hard work of it if that is what you are doing. Just select the value directly from the database.

Forath
New php-forum User
New php-forum User
Posts: 19
Joined: Sat Jun 17, 2017 1:07 pm

Sun Feb 18, 2018 12:34 pm

There in lies the rub,

the value drawn from the db is an abbreviation and is used as a reference for multiple things displayed on webpage..

the team array assigns a full value to that abbreviation, which is necessary for a new section of the page. The idea is to be able to piggyback already existing db result sets and use it to reference a new list array, that is being built into the page..

chorn
php-forum Fan User
php-forum Fan User
Posts: 564
Joined: Fri Apr 01, 2016 2:18 am

Sun Feb 18, 2018 11:01 pm

that should give you a syntax error. did you read it? there is no need for string concatenation.

Forath
New php-forum User
New php-forum User
Posts: 19
Joined: Sat Jun 17, 2017 1:07 pm

Mon Feb 19, 2018 11:15 am

Thanks.. wasn't getting any error output on page, so pushed it through a code tester to eval the error..

All sorted, output works now. Cheers

Post Reply