RE: [PHP-DB] Putting a string into a variable.
| From: | Hutchins, Richard | Date: | Fri, 28 Mar 2003 19:21:40 +0000 |
| Subject: | RE: [PHP-DB] Putting a string into a variable. | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-26676@lists.php.net to get a copy of this message | ||
You might be getting an empty result because you don't have anything in
$stringarray[1]. You set $i = 0 then have a while loop that does something
while $i < 6. But you never go through and increment $i at all so it's
always equal to 0. You might get some type of result if you echoed
$stringarray[0] in that case.
You should use a for loop and remember to increment ($i++) the variable in
the appropriate place inside the for loop.
Additionally, I think the proper way to accomplish your array assignment is
to state $stringarray = array(). I seem to remember reading somewhere that
$stringarray[] = array() isn't quite correct. It works, but it's not
correct.
It's Friday, it's nice outside and I'm not concentrating much, so I hope
this information is of some help.
Good luck,
Rich
> -----Original Message-----
> From: Info_Best-IT [mailto:info@best-it.biz]
> Sent: Friday, March 28, 2003 2:13 PM
> To: php-db@lists.php.net
> Subject: [PHP-DB] Putting a string into a variable.
>
>
> I am having problems putting an html string into a variable
> to create an array of
> strings.
>
> something like this:
>
>
> $stringarray[] = array();
> $i = 0;
>
> while ( $i < 6 ){
> $stringarray[$i] = "<table
> cellspacing=\"0\"><tr><td>".$this->differentarray[0]
> [0]."</td></tr></table>";
> }
>
>
> When I echo $stringarray[1] it comes up empty... Is there a
> special trick to get a
> string into an array or even store one as a variable.
>
> thanks,
> /Tim
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>