Hello,
If I have variable names in a text file how can I use those names as variables?
I have "cont" as a string in a file. That is read in using fopen. How can I use $cont as my variable?
Variable Names
Started by Paradine, Oct 22 2006 03:23 PM
3 replies to this topic
#1
Posted 22 October 2006 - 03:23 PM
|
|
|
#2
Posted 31 October 2006 - 09:52 PM
I believe when you use fopen, the entire content of the file is stored as a string. Therefor you would need to use some method to parse the content. Either using regex or some string functions such as sscanf.
#3
Posted 02 November 2006 - 06:27 AM
So you want to turn a string into a variable? Why? You could always use an array to do this:
so to apply you would use
Where $str is the variable name from the text file.
$myArray['cont']
so to apply you would use
$myArray[$str]->'value';
Where $str is the variable name from the text file.
#4
Posted 03 November 2006 - 09:29 AM
Yes, I need the variable name to be the array. I suppose I could use an array but it is just easier when going through the list again to say print $variable instead of finding the name and searching an array.


Sign In
Create Account


Back to top









