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 arr

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: http://www.php.n

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

[PHP] Variable Question

2012-04-19 Thread Ron Piggott
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’] I am trying to use this while look to assign them to variables: $word_1 $word_2 $word_3 ... $word_

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 e

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 = "trivia_answer_.$correct_ans

Re: [PHP] Variable question

2011-10-01 Thread Tim Streater
On 01 Oct 2011 at 18:59, 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 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 David Harkness
On Sat, Oct 1, 2011 at 10:59 AM, 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? You can use variable variables [1] to access the variable by building its name in a string: $name = 'trivia_ans

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_answe

[PHP] Variable question

2011-10-01 Thread Ron Piggott
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; $trivia_answer_1 = “1,000”; $trivia_answer_2 = “1,250”; $tr

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 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=

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 yo

[PHP] variable question

2004-06-19 Thread water_foul
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...

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!"; > > Tha

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

[PHP] variable question...

2002-04-15 Thread Phil Schwarzmann
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 I just wrote will not print out "Hello!" THA

Re: [PHP] variable question

2002-04-15 Thread cal
ROTECTED]> To: <[EMAIL 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 > > $File = "welcome/index.php";

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 Jule On Monday 15 April 2002 13:49, you typed on your keyboard, and you sent me the following: On Tuesday 16 April 2002 00:41, Jule Slootbe

RE: [PHP] variable question

2002-04-15 Thread David McInnis
ww.php.net/manual/en/function.explode.php 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&#x

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 > th

[PHP] variable question

2002-04-15 Thread Jule Slootbeek
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? when i just do fopen and fwrite it prints both variables.

Re: [PHP] Variable question, yet another

2001-05-09 Thread Gyozo Papp
MAIL PROTECTED]> Cc: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL 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 eva

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 s

[PHP] Variable question, yet another

2001-05-08 Thread King, Justin
Alright... here's my situation for those that didn't read my string of messages yesterday.. (plus a bit more background information as to why I'm doing this) I'm writing an engine for a content managing system. Part of the system is a menu builder. I use 2 tables, (this is a mysql database) me

RE: [PHP] Variable question

2001-05-07 Thread ..s.c.o.t.t.. [gts]
stin [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 07, 2001 4:29 PM > To: [EMAIL PROTECTED] > 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 &g

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

2001-05-07 Thread ..s.c.o.t.t.. [gts]
]] > Sent: Monday, May 07, 2001 4:21 PM > To: King, Justin; [EMAIL PROTECTED] > Subject: 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, GameDesi

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: R

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]>, [E

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 PH

RE: [PHP] Variable question

2001-05-07 Thread John Vanderbeck
tin [mailto:[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"]&qu

RE: [PHP] Variable question

2001-05-07 Thread King, Justin
D]> Sent: Monday, May 07, 2001 1:13 PM To: 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] Variab

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

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 (http://www

RE: [PHP] Variable question

2001-05-07 Thread John Vanderbeck
John Vanderbeck - Admin, GameDesign (http://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] &

RE: [PHP] Variable question

2001-05-07 Thread King, Justin
al Message- From: "Jack Dempsey" <[EMAIL 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 u

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]&g

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: [

[PHP] Variable question

2001-05-07 Thread King, Justin
How can I evaluate a variable in a string? For example if I have a string defined as "my user name is $user_data["username"]", how do I echo that string and have php evaluate $user_data["username"]. Thanks in advance.. -Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

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 exa

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, Ja

[PHP] variable question

2001-01-19 Thread Michael Zornek
ok so i have an object that has (among other things) the following properties: $vendor_data->s9 $vendor_data->s10 $vendor_data->s11 $vendor_data->s12 ... $vendor_data->s40 The values are 1 or 0 I'd like to write a loop to say: for ($count=9; $count>40; $count++) { if ($vendor_data->s(i