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
> 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
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
> -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 $
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
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;
>
> $
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 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
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
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
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=
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
> -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
"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
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";
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
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
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
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
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
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
]]
> 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
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
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
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
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
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
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
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
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]
&
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
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
Ho
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
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
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
35 matches
Mail list logo