Re: hrm... varaible varaibles and looping
| From: | Lars Torben Wilson | Date: | Tue, 14 Nov 2000 05:09:46 +0000 |
| Subject: | Re: hrm... varaible varaibles and looping | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-25113@lists.php.net to get a copy of this message | ||
Kurth Bemis writes:
> look at this
>
> i have $cart with "fields" separated by ':'. i explode the
> variable...however..i can't get it to loop and add one to the variable that
> points to the array...i can't figure out how to lloop until the end of the
> array is reached.....any ideas?
>
> look at the code.
Where's the loop? It's not quite clear what you're attempting to do
here. Can you include the loop itself and explain a bit more exactly
what effect you're going for?
> if (session_is_registered("cart")){
> $cartitem = "item[".$numofitems ."]"; //set cartitem to item[#]
> $cartarray = explode (":",$cart); //separate cart at the colons
> if ($cartarray){
> $$cartitem = $cartarray[$numofitems]; //make $$cartitem equal to item[#]
> and then set that to cartarray[#]
> $numofitems++; //duh
> echo $cartitem;
> }elseif (!$cartarray){
> echo "done!";
> }
>
> }else{
> session_register("cart");
> }
>
> ~kurth
> Kurth Bemis - Network/Systems Administrator, USAExpress.net/Ozone Computer
>
> There is no sin except stupidity. -- Oscar Wilde
>
> kurth@usaexpress.net | http://www.usaexpress.net/kurth
> PGP key available - http://www.usaexpress.net/kurth/pgp
>
> Fight Weak Encryption! Donate your wasted CPU cycles to Distributed.net
> (http://www.distributed.net)
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+