Re: assign values to variables, all taken from txt file

From: Date: Tue, 15 May 2001 11:26:34 +0000
Subject: Re: assign values to variables, all taken from txt file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-52835@lists.php.net to get a copy of this message
So now my code looks like: ----------------------------------- $configuration_data = file("configuration.txt"); for($index=0; $index < count($configuration_data); $index++) { $line = explode(" // ",$configuration_data[$index]); $value = $line[0]; $variable = $line[1]; $$variable = $value; echo "$variable:<b>$value</b><br>\n"; } echo "$admin_email$sys_host$root_path$www\n<hr>\n"; ------------------------------------ And there is still something wrong, because it does print me a good list $variable_name:corresponding_value from the echo inside the loop, but the echo at the end doesn't return any value... I'm still missing something there... :( -Alain- ""Tobias Talltorp"" <tobias@talltorp.com> wrote in message news:9dr0g8$cgs$1@toye.p.sourceforge.net... > From what I could see you want variable variables > $value = $line[0]; > $variable = $line[1]; > $$variable = $value; > > // Tobias > > ""Alain"" <alainygr@evitech.fi> wrote in message > news:9dqrh1$23a$1@toye.p.sourceforge.net... > > Hello, > > I am trying to get values assigned to variables, by taking these data from > a > > textfile. > > my txt file looks like that: > > variable1 // value1 > > variable2 // value2 > > etc... > > The point here is that I want to be able to get BOTH the variable name and > > its corresponding value.. > > I tried things like: > > ----------//----------- > > $configuration_data = file("conf/configuration.txt"); > > for($index=0; $index < count($configuration_data); $index++) > > { > > $line = explode("//",$configuration_data[$index]); > > $value = "$line[0]"; > > $variable = "$line[1]"; > > $"\$variable" = "$value"; > > } > > ----------//------------ > > So it's that "$"\$variable" = "$value";" which is wrong > > and now I don't > have > > any inspiration anymore... > > > > Could somebody help me pleeeease?! > > thanks, > > -Alain- > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#52835) next »