We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,605 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Variable equal to variable+string

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'

3
Contributors
3
Replies
1 Day
Discussion Span
3 Months Ago
Last Updated
5
Views
Question
Answered
fheppell
Junior Poster in Training
50 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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?

LastMitch
Industrious Poster
4,118 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

You can use $$ to set var names.

diafol
Keep Smiling
Moderator
10,610 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57

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

fheppell
Junior Poster in Training
50 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 3 Months Ago by diafol and LastMitch

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0694 seconds using 2.83MB