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
...
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
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:
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
-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
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”;
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;
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:
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:
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
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 =
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
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
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,
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
-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
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
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?
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
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);
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
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!
THANKS!!!
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
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
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)
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
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,
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
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
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
://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
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
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
; [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
:[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
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
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
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
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
]
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
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,
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
42 matches
Mail list logo