RE: [PHP] Varible Varibles

2002-06-13 Thread John Holmes

I think you're missing the point of variable variables.

?
$a = 'foo';
$$a = 'bar';

echo $a $$a;
?

After the first use of $$a, you now have a variable called $foo with a
value of 'bar'.

So your echo would be echo $a $foo;

I kind of consider variable variables the poor mans array. Most any
solution you think of with variable variables could be better solved by
using arrays.

---John Holmes...

 -Original Message-
 From: Peter [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, June 12, 2002 10:42 PM
 To: Php
 Subject: [PHP] Varible Varibles
 
 howdy,
 I'm just curious here about varible varibles ... I know that you can,
well
 it's documented that you can, do the following
 
 ?
 $a = foo;
 $$a = bar;
 
 echo $a $$a;
 ?
 
 which will produce  foo bar
 
 now what I am curious about is, how much of a difference does that
really
 make when you compare it to..
 
 ?
 $a = foo;
 $a .= bar;
 
 echo $a;
 ?
 
 
 
 
 Cheers
 
 Peter
 the only dumb question is the one that wasn't asked
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Varible Varibles

2002-06-13 Thread Pushkar Pradhan

I'm trying to use variable variables to work on arrays:
$forest = array(a, b, c, ...);

$layer[$l]= forest;

Now I want to access all array members of $forest using $$layer:
e.g.
for($c = 0; $c  $$layer[$l]; $l++) {
   echo $$layer[$l][$c];
}
But this doesn't work, gives syntax error,
So my workaround is:
$new = $$layer[$l];
$new[$c] refers all elements of array $forest
Is this the best workaround or am I missing something?

 I think you're missing the point of variable variables.

 ?
 $a = 'foo';
 $$a = 'bar';

 echo $a $$a;
 ?

 After the first use of $$a, you now have a variable called $foo with a
 value of 'bar'.

 So your echo would be echo $a $foo;

 I kind of consider variable variables the poor mans array. Most any
 solution you think of with variable variables could be better solved by
 using arrays.

 ---John Holmes...

  -Original Message-
  From: Peter [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, June 12, 2002 10:42 PM
  To: Php
  Subject: [PHP] Varible Varibles
 
  howdy,
  I'm just curious here about varible varibles ... I know that you can,
 well
  it's documented that you can, do the following
 
  ?
  $a = foo;
  $$a = bar;
 
  echo $a $$a;
  ?
 
  which will produce  foo bar
 
  now what I am curious about is, how much of a difference does that
 really
  make when you compare it to..
 
  ?
  $a = foo;
  $a .= bar;
 
  echo $a;
  ?
 
 
 
 
  Cheers
 
  Peter
  the only dumb question is the one that wasn't asked
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-Pushkar S. Pradhan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Varible Varibles

2002-06-13 Thread Jason Wong

On Friday 14 June 2002 00:38, John Holmes wrote:
 I think you're missing the point of variable variables.

Quite :-)

 I kind of consider variable variables the poor mans array. Most any
 solution you think of with variable variables could be better solved by
 using arrays.

Actually variable variables are extremely powerful in the cases where they 
_really_ are needed. However some people mistakenly use variable variables 
when they really should be using arrays.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
If I can have honesty, it's easier to overlook mistakes.
-- Kirk, Space Seed, stardate 3141.9
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Varible Varibles

2002-06-12 Thread Martin Towell

well, the first method is the same as saying
$a = foo;
$foo = bar;
echo $a $foo;

whereas the second method is appending bar to $a (thus making it foobar)

In first method, you get two variables, the second, just one

-Original Message-
From: Peter [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 13, 2002 12:42 PM
To: Php
Subject: [PHP] Varible Varibles


howdy,
I'm just curious here about varible varibles ... I know that you can, well
it's documented that you can, do the following

?
$a = foo;
$$a = bar;

echo $a $$a;
?

which will produce  foo bar

now what I am curious about is, how much of a difference does that really
make when you compare it to..

?
$a = foo;
$a .= bar;

echo $a;
?




Cheers

Peter
the only dumb question is the one that wasn't asked



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Varible Varibles

2002-06-12 Thread Peter

Ok,...

what sort situations would you benifit using the first method?

ie

is it more suiteable to making some conditions

eg

$a = foo;
while {$$a = bar)
echo $a;
endwhile;







-Original Message-
From: Martin Towell [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 13 June 2002 12:44 PM
To: 'Peter'; Php
Subject: RE: [PHP] Varible Varibles


well, the first method is the same as saying
$a = foo;
$foo = bar;
echo $a $foo;

whereas the second method is appending bar to $a (thus making it foobar)

In first method, you get two variables, the second, just one

-Original Message-
From: Peter [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 13, 2002 12:42 PM
To: Php
Subject: [PHP] Varible Varibles


howdy,
I'm just curious here about varible varibles ... I know that you can, well
it's documented that you can, do the following

?
$a = foo;
$$a = bar;

echo $a $$a;
?

which will produce  foo bar

now what I am curious about is, how much of a difference does that really
make when you compare it to..

?
$a = foo;
$a .= bar;

echo $a;
?




Cheers

Peter
the only dumb question is the one that wasn't asked



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php