PHP - adding letters to a variable to target another variable

Hi,


Im trying to append letters to a variable to output another variable.

I have 2 variables

 $casestudy->job_title
and
$casestudy->job_title_fr

To ouput the latter im adding the letters "_fr" via a session variable i.e.
$casestudy->job_title.$_SESSION['language']
where
$_SESSION['language'] =  "_fr".

However this does not work.

Any ideas?


thanks
coolispaulAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
$casestudy->{"job_title".$_SESSION['language'] }

Open in new window

Though why not just extend the object?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
coolispaulAuthor Commented:
perfect thanks!

what do you mena by extending the onject?

Thanks
0
Marco GasiFreelancerCommented:
AFAK, you can't. Th variable $casestudy->job_title is a object property and you can't create a property at run-time. You ccan easily use a switch o check if language id _fr or someone else and give to $casestudy->job_title a different valu. If you want to explain with more  details wht exactly you need to do, may be we can give a better hep.

Cheers.
0
GaryCommented:
Forget my extending I thought you were trying to create it initially.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.