Hi,
I've been playing with this for a while now. Say I had the following variables:
$name1 = joe;
$name2 = janis;
$name3 = joanne;
Is there a way in php to increment the variable name not the value? Something like
this
for ($i = 1; $i = 3; $i++) {
$arr_name[$i] = $name.$i; // I
Incrementing a Variable name?
Hi,
I've been playing with this for a while now. Say I had the following
variables:
$name1 = joe;
$name2 = janis;
$name3 = joanne;
Is there a way in php to increment the variable name not the value?
Something like this
for ($i = 1; $i = 3; $i++) {
$arr_name[$i
You're on the right track:
for ($i = 1; $i = 3; $i++) {
$arr_name[$i] = $name$i; // I want $name1,$name2,$name3 etc
}
- Original Message -
From: Jeff Pauls [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, February 25, 2003 3:18 PM
Subject: [PHP] Auto Incrementing
$name1 = 'Hello, World!';
$i = 1;
$var = 'name'.$i;
print ${$var};
HTH,
Jason k Larson
Jeff Pauls wrote:
Hi,
I've been playing with this for a while now. Say I had the following variables:
$name1 = joe;
$name2 = janis;
$name3 = joanne;
Is there a way in php to increment the variable name not the
]; [EMAIL PROTECTED]
Sent: Tuesday, February 25, 2003 3:26 PM
Subject: Re: [PHP] Auto Incrementing a Variable name?
You're on the right track:
for ($i = 1; $i = 3; $i++) {
$arr_name[$i] = $name$i; // I want $name1,$name2,$name3 etc
}
- Original Message -
From: Jeff Pauls
-
From: Rick Emery [EMAIL PROTECTED]
To: Jeff Pauls [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, February 25, 2003 3:26 PM
Subject: Re: [PHP] Auto Incrementing a Variable name?
You're on the right track:
for ($i = 1; $i = 3; $i++) {
$arr_name[$i] = $name$i; // I want $name1,$name2
- Original Message -
From: Jason k Larson [EMAIL PROTECTED]
To: Jeff Pauls [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, February 25, 2003 3:37 PM
Subject: Re: [PHP] Auto Incrementing a Variable name?
$name1 = 'Hello, World!';
$i = 1;
$var = 'name'.$i;
print ${$var};
HTH,
Jason k
]
To: Jeff Pauls [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, February 25, 2003 3:26 PM
Subject: Re: [PHP] Auto Incrementing a Variable name?
You're on the right track:
for ($i = 1; $i = 3; $i++) {
$arr_name[$i] = $name$i; // I want $name1,$name2,$name3 etc
}
- Original Message
8 matches
Mail list logo