hrm... varaible varaibles and looping
| From: | Kurth Bemis | Date: | Tue, 14 Nov 2000 03:53:01 +0000 |
| Subject: | hrm... varaible varaibles and looping | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-25111@lists.php.net to get a copy of this message | ||
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.
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)