Re: [PHP] Variable Question

2012-04-19 Thread Stuart Dallas
On 19 Apr 2012, at 15:46, Ron Piggott wrote: I am trying to assign variables from an array into variables. This is following a database query. Right now they are in an array: $row[‘word_1’] $row[‘word_2’] $row[‘word_3’] ... $row[‘word_25’] Why those indices? Why isn't it just a

Re: [PHP] Variable Question

2012-04-19 Thread Christoph Boget
I am trying to use this while look to assign them to variables: $word_1 $word_2 $word_3 ... $word_25 This should work for you: http://us3.php.net/manual/en/function.extract.php thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] Variable Question

2012-04-19 Thread Shawn McKenzie
On 04/19/2012 09:55 AM, Christoph Boget wrote: I am trying to use this while look to assign them to variables: $word_1 $word_2 $word_3 ... $word_25 This should work for you: http://us3.php.net/manual/en/function.extract.php thnx, Christoph Yes and you can use

RE: [PHP] Variable question

2011-10-03 Thread Ford, Mike
-Original Message- From: Ron Piggott [mailto:ron@actsministries.org] Sent: 01 October 2011 18:59 To: php-general@lists.php.net Subject: [PHP] Variable question If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of

Re: [PHP] Variable question

2011-10-01 Thread Mike Mackintosh
On Oct 1, 2011, at 1:59 PM, Ron Piggott wrote: If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? I know this is incorrect, but along the lines of what I am wanting to do: echo $trivia_answer_$correct_answer;

Re: [PHP] Variable question

2011-10-01 Thread David Harkness
On Sat, Oct 1, 2011 at 10:59 AM, Ron Piggott ron@actsministries.orgwrote: If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? You can use variable variables [1] to access the variable by building its name in a string:

Re: [PHP] Variable question

2011-10-01 Thread Robert Cummings
On 11-10-01 02:03 PM, Mike Mackintosh wrote: On Oct 1, 2011, at 1:59 PM, Ron Piggott wrote: If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? I know this is incorrect, but along the lines of what I am wanting to do:

Re: [PHP] Variable question

2011-10-01 Thread Tim Streater
On 01 Oct 2011 at 18:59, Ron Piggott ron@actsministries.org wrote: If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? I know this is incorrect, but along the lines of what I am wanting to do: echo

Re: [PHP] Variable question

2011-10-01 Thread Geoff Shang
On Sat, 1 Oct 2011, Mike Mackintosh wrote: Best bet would to toss this into either an object or array for simplification, otherwise that type of syntax would need the use of eval. example: eval('echo $trivia_answer_'.$correct_answer.';'); You could do: $var =

Re: [PHP] variable question

2004-06-20 Thread Daniel Clark
How about: eval( '$lie' . x ) ; is there a way to use one variable to create another? Example $poo=1 and i want $lie1 OR $poo=2 and i want $lie2 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] variable question

2004-06-19 Thread Robin Vickery
On Sat, 19 Jun 2004 14:25:27 -0600, water_foul [EMAIL PROTECTED] wrote: is there a way to use one variable to create another? Example $poo=1 and i want $lie1 OR $poo=2 and i want $lie2 If I understand you right, you want: ${'lie' . $poo} when $poo is 1, that will give you $lie1,

Re: [PHP] variable question

2004-06-19 Thread water_foul
Thanks oh so much Robin Vickery [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sat, 19 Jun 2004 14:25:27 -0600, water_foul [EMAIL PROTECTED] wrote: is there a way to use one variable to create another? Example $poo=1 and i want $lie1 OR $poo=2 and i want $lie2

RE: [PHP] variable question...

2002-04-16 Thread Ford, Mike [LSS]
-Original Message- From: Justin Blake [mailto:[EMAIL PROTECTED]] Sent: 16 April 2002 09:43 You can use variable variable names by adding another '$'. so if $i == 1 and $var1 == one, you can do this: $var_name = var.$i; if($$var_name == one) echo Hello!; That should work, So

Re: [PHP] variable question

2002-04-15 Thread Jason Wong
On Tuesday 16 April 2002 00:41, Jule Slootbeek wrote: Hey Guys and Gals, I'm writing this little script that takes two inputs: $name and $welcomemssg from a form and puts them in a text file. Now i only want to extract one of those variables open it with welcome.php, how do i go about this?

RE: [PHP] variable question

2002-04-15 Thread David McInnis
David McInnis -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Monday, April 15, 2002 10:49 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] variable question On Tuesday 16 April 2002 00:41, Jule Slootbeek wrote: Hey Guys and Gals, I'm writing this little script

Re: [PHP] variable question

2002-04-15 Thread Jule Slootbeek
Here's my code, teh $welcomemssg is one of the two variable store in index.php the other one is $name ?php $File = welcome/index.php; $Open = fopen ($File, r);

Re: [PHP] variable question

2002-04-15 Thread cal
PROTECTED] Sent: Monday, April 15, 2002 1:30 PM Subject: Re: [PHP] variable question Here's my code, teh $welcomemssg is one of the two variable store in index.php the other one is $name ?php $File = welcome/index.php; $Open = fopen ($File, r); if ($Open) { print ($welcomemssg

Re: [PHP] variable question...

2002-04-15 Thread Justin Blake
Phil Schwarzmann [EMAIL PROTECTED] wrote: Let's say I a variable called $var1 and it's values is one ...I want to access them by doing something like this... $i = 1; if (var.$i == one) echo Hello!; ...I want the combination of var and $i to equal $var1 How do I do this?? The code

Re: [PHP] Variable question, yet another

2001-05-09 Thread Gyozo Papp
PROTECTED] Sent: 2001. május 8. 21:22 Subject: Re: [PHP] Variable question, yet another On Tue, May 08, 2001 at 01:20:49PM -0500, King, Justin wrote: So when the line hits type 1, it evals like this echo [a href=myscript.php?username={$userdata[username]}]Goto MyScript.php

Re: [PHP] Variable question, yet another

2001-05-08 Thread Jason Stechschulte
On Tue, May 08, 2001 at 01:20:49PM -0500, King, Justin wrote: So when the line hits type 1, it evals like this echo [a href=myscript.php?username={$userdata[username]}]Goto MyScript.php[/a]; Of course this yields an error because of the 's in the anchor tag. But if I add slashes the

RE: [PHP] Variable question

2001-05-07 Thread Jack Dempsey
you can do it a couple ways... echo my user name is . $user_data[username]; or echo my username is ${user_data[username]}; -Original Message- From: King, Justin [mailto:[EMAIL PROTECTED]] Sent: Monday, May 07, 2001 3:49 PM To: [EMAIL PROTECTED] Subject: [PHP] Variable question How

Re: [PHP] Variable question

2001-05-07 Thread Gyozo Papp
Try this one : $user_data['username'] = 'Alphonse'; $str = my user name is {$user_data['username']}; Papp Gyozo - [EMAIL PROTECTED] - Original Message - From: King, Justin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: 2001. május 7. 21:48 Subject: [PHP] Variable question How can I

RE: [PHP] Variable question

2001-05-07 Thread King, Justin
PROTECTED] Sent: Monday, May 07, 2001 12:55 PM To: King, Justin; [EMAIL PROTECTED] Subject: RE: [PHP] Variable question you can do it a couple ways... echo my user name is . $user_data[username]; or echo my username is ${user_data[username]}; -Original Message- From: King, Justin [mailto

RE: [PHP] Variable question

2001-05-07 Thread John Vanderbeck
://gamedesign.incagold.com/) - GameDesign, the industry source for game design and development issues -Original Message- From: King, Justin [mailto:[EMAIL PROTECTED]] Sent: Monday, May 07, 2001 3:58 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] Variable question I think you're

RE: [PHP] Variable question

2001-05-07 Thread King, Justin
Here let me flesh this out a bit more Consider the query SELECT datafield FROM myTable WHERE id=1; This would return My username is $userdata[username]; I want to then output what the database returns, and have php evaluate my variables. -Justin -- PHP General Mailing List

RE: [PHP] Variable question

2001-05-07 Thread Jack Dempsey
ok, look into eval() -Original Message- From: King, Justin [mailto:[EMAIL PROTECTED]] Sent: Monday, May 07, 2001 4:07 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] Variable question Here let me flesh this out a bit more Consider the query SELECT datafield FROM myTable WHERE id=1

RE: [PHP] Variable question

2001-05-07 Thread King, Justin
; [EMAIL PROTECTED] Subject: RE: [PHP] Variable question ok, look into eval() -Original Message- From: King, Justin [mailto:[EMAIL PROTECTED]] Sent: Monday, May 07, 2001 4:07 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] Variable question Here let me flesh this out a bit more Consider

RE: [PHP] Variable question

2001-05-07 Thread John Vanderbeck
:[EMAIL PROTECTED]] Sent: Monday, May 07, 2001 4:18 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] Variable question A simple eval($mysqldata) isn't going to do it though since the string is Your username is $userdata[username]; it'll just spit a parse error. I've already tried that -Justin

Re: [PHP] Variable question

2001-05-07 Thread CC Zona
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (King, Justin) wrote: A simple eval($mysqldata) isn't going to do it though since the string is Your username is $userdata[username]; it'll just spit a parse error. I've already tried that The code being eval'd has to be a valid PHP

RE: [PHP] Variable question

2001-05-07 Thread King, Justin
I understand that, but that's what I'm trying to get around doing. -Justin -Original Message- From: CC Zona [EMAIL PROTECTED] Sent: Monday, May 07, 2001 1:24 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Variable question In article [EMAIL PROTECTED], [EMAIL PROTECTED] (King, Justin

RE: [PHP] Variable question

2001-05-07 Thread King, Justin
I'm trying to get around having to do that, I don't know regular expressions so it makes it difficult :( -Justin -Original Message- From: John Vanderbeck [EMAIL PROTECTED] Sent: Monday, May 07, 2001 1:21 PM To: King, Justin; [EMAIL PROTECTED] Subject: RE: [PHP] Variable question How

RE: [PHP] Variable question (eval is cool)

2001-05-07 Thread ..s.c.o.t.t.. [gts]
: RE: [PHP] Variable question How about manually parsing the string out to give you chunks, that can then be eval'd easy. - John Vanderbeck - Admin, GameDesign (http://gamedesign.incagold.com/) - GameDesign, the industry source for game design and development issues -Original

RE: [PHP] Variable question

2001-05-07 Thread ..s.c.o.t.t.. [gts]
] Subject: RE: [PHP] Variable question I'm trying to get around having to do that, I don't know regular expressions so it makes it difficult :( -Justin -Original Message- From: John Vanderbeck [EMAIL PROTECTED] Sent: Monday, May 07, 2001 1:21 PM To: King, Justin; [EMAIL

Re: [PHP] variable question

2001-01-19 Thread Joe Stump
Put them in an array? PHP allows for variable variables, but I'm not sure they work with classes. This works: $foo0 = 'a'; $foo1 = 'b'; $foo2 = 'c'; $foo3 = 'd'; $foo4 = 'e'; for($i = 0 ; $i 5 ; ++$i) { $var = 'foo'.$i; echo $$var; } Try it with an object... --Joe On Fri,

Re: [PHP] variable question

2001-01-19 Thread Chris Lee
thats right you could do that, but it sucks. (IMHO) $test-s0 $test-s1 $test-s2 for($c = 0; $c 3; $c++) { $name = "s$c"; echo $test-$name; } but this is better, more modular. $test-s[0] $test-s[1] $test-s[2] foreach($test-s as $pos = $val) echo $val; with the second example you