Change variable name

Change variable name

am 23.04.2007 11:46:19 von Boris Savc

Sorry for confuzing subject, but that's the thing I'm trying to achieve. For
example:

$a = "Hello";
$b = 1;

I want to change the name of $a to $a1 where 1 is value of variable $b!

Thanks for all the help,
Boris

Re: Change variable name

am 23.04.2007 13:38:45 von zac.carey

On Apr 23, 10:46 am, "Boris Savc" wrote:
> Sorry for confuzing subject, but that's the thing I'm trying to achieve. For
> example:
>
> $a = "Hello";
> $b = 1;
>
> I want to change the name of $a to $a1 where 1 is value of variable $b!
>
> Thanks for all the help,
> Boris

This has nothing to do with sql, but anyway:

$a = "hello";
$b = "world";
$a.= $b;
echo $a;
?>

Re: Change variable name

am 23.04.2007 14:58:49 von Captain Paralytic

On 23 Apr, 12:38, strawberry wrote:
> On Apr 23, 10:46 am, "Boris Savc" wrote:
>
> > Sorry for confuzing subject, but that's the thing I'm trying to achieve. For
> > example:
>
> > $a = "Hello";
> > $b = 1;
>
> > I want to change the name of $a to $a1 where 1 is value of variable $b!
>
> > Thanks for all the help,
> > Boris
>
> This has nothing to do with sql, but anyway:
>
> > $a = "hello";
> $b = "world";
> $a.= $b;
> echo $a;
> ?>

That would produce "helloworld"

He didn't say that he wanted to concatenate the contents, he said he
wanted a new variable name.

I have to wonder why he wants to do this. I would normally use an
associative array:

$a[$b] = $a;

but you could say:

$b = "a{$b}";
$$b = $a;
unset($a);

Re: Change variable name

am 23.04.2007 15:15:04 von zac.carey

On Apr 23, 1:58 pm, Captain Paralytic wrote:
> On 23 Apr, 12:38, strawberry wrote:
>
>
>
> > On Apr 23, 10:46 am, "Boris Savc" wrote:
>
> > > Sorry for confuzing subject, but that's the thing I'm trying to achieve. For
> > > example:
>
> > > $a = "Hello";
> > > $b = 1;
>
> > > I want to change the name of $a to $a1 where 1 is value of variable $b!
>
> > > Thanks for all the help,
> > > Boris
>
> > This has nothing to do with sql, but anyway:
>
> > > > $a = "hello";
> > $b = "world";
> > $a.= $b;
> > echo $a;
> > ?>
>
> That would produce "helloworld"
>
> He didn't say that he wanted to concatenate the contents, he said he
> wanted a new variable name.
>
> I have to wonder why he wants to do this. I would normally use an
> associative array:
>
> $a[$b] = $a;
>
> but you could say:
>
> $b = "a{$b}";
> $$b = $a;
> unset($a);

oops

my turn to skulk away embarrased