Guess its something like
$pref = "case";
for($i=0;$i<$numnames;$i++){
${$pref.$names[$i]} = new Test($name[$i]);
}
__
Stefan
> -----Urspr�ngliche Nachricht-----
> Von: bob pilly [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 24. November 2004 12:52
> An: [EMAIL PROTECTED]
> Betreff: [PHP] Dynamic Class Name Assignments
>
> Hi All, im new to classes in PHP. Im trying to create
> several instances of a very basic class but i want
> each name to be based on number values in an array and
> im not sure if it is allowed and if so how to do it. I
> assume that im not allow to have a var starting with a
> number so what i am trying to do is add the word case
> to the front of the class instance name so i would
> have $case100,$case101 etc. Im am using PHP 5.02.
> Heres my code
>
> <?php
>
> class Test
> {
> //members
> var $caseid,$fee;
>
> function Test($caseid){
> $this->caseid=$caseid;
> }
>
> function addmember($membername,$value){
> $this->$membername=$value;
> }
> }
>
> $names=array("100","101","102","104");
> $numnames=count($names);
> for($i=0;$i<$numnames;$i++){
> *** below is the syntax im missing ***
> $case.$names[$i] = new Test($names[$i]);
> }
> var_dump($case100);
> ?>
>
> Thanks for any help in advance!
>
> Cheers
>
> Bob Pilford
>
>
>
>
>
> ___________________________________________________________
> ALL-NEW Yahoo! Messenger - all new features - even more fun!
> http://uk.messenger.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php