Re: variable string names
| From: | Leif K-Brooks | Date: | Sun, 09 Mar 2003 03:50:44 +0000 |
| Subject: | Re: variable string names | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138824@lists.php.net to get a copy of this message | ||
for ($i=1; $i<=8 i++)
{
if (${'where'.$i} != '')
{
$whereArray = array_push($whereArray, ${'where'.$i});
}
}
julian haffegee wrote:
Hi all, I have something thats been driving me mad for days I have: if ($where1 != '') { $whereArray = array_push($whereArray, $where1); } and I want to repeat for $where1 up to $where8 but rather than write it out 8 times, I'd rather use a loop for ($i=1; $i<=8 i++) { if ($where1 != '') { $whereArray = array_push($whereArray, $where1); } } but how can I change $where1 to $where2, $where3 etc using $i. nothing I try seems to work. Do I use eval? Thanks for any help given Jules-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.