Re: Need help with variables - SOLVED!
| From: | Michel Laine | Date: | Wed, 27 Jun 2001 09:18:48 +0000 |
| Subject: | Re: Need help with variables - SOLVED! | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-8073@lists.php.net to get a copy of this message | ||
This is the code snippet from my original message:
>
> // Do it!
> for ($i = 0; $i <= 34; $i++) {
>
> // Need help with this part
> $j = $i + 1;
> $var = ${"DAY".$j};
> $val = $day[$i];
>
> // Set PHPLIB Template variable
> $t->set_var( $var => $val );
>
> }
>
> // Do the rest (like parse templates)
>
Well - what can i say?
Thank you all for helping me out!
The problem is pretty obvious (now that i know how to solve it) - It's a
typo/type combination.
I should use the line:
$var = "DAY" . $j; // $var is a string "DAYn"
As pointed out by Ruslan Ohitin.
Then i should correct the typo i have in my original code snippet (included
above):
$t->set_var( $var => $val ); should be $t->set_var( $var , $val );
Funny thou, i got no replies about this error. Didn't anyone see it?
The $t->set_var(array( $var => $val )); syntax is used when you have arrays
of variables.
I guess that this is a good pointer for that i shouldn't use cut'n'paste as
often as i do ;-)
Guess who looks like a fool?
Thanks again!
--
Michel Laine