1,105,328 Community Members

Variable equal to variable+string

Member Avatar
fheppell
Junior Poster
125 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

I have a variable called $file, this is from a GET query. I need the variable $file_humanreadto be equal to whatever file is with humanname appended.
For example, if file is equal to 'test', I need the variable $file_humanread to be equal to $test_humanread, which is set already.

I've tried:
$file_humanread= $file, "_humanread"
But when I echo the variable it comes out as: _humanread It should have echoed the contents of the variable $test_humanread, which is 'Foo Bar'

LastMitch
Deleted Member
 
0
 

But when I echo the variable it comes out as: _humanread It should have echoed the contents of the variable $test_humanread, which is 'Foo Bar'

Can you post a little more code.

This 1 line is not very helpful:

$file_humanread= $file, "_humanread"

The reason why I ask is because I don't know if you are using a form to get the the data or what is the variable in $file?

Member Avatar
diafol
Where are my eyes?
12,963 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,847 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

You can use $$ to set var names.

Member Avatar
fheppell
Junior Poster
125 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

Fixed with $file_humanread = ${$file . "humanread"};

Question Answered as of 1 Year Ago by diafol and LastMitch
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: