Page 1 of 1

Need help getting PHP to translate string as variable

Posted: Wed Jan 14, 2004 1:29 pm
by Thyme3333

Code: Select all

<?php
function GetStruct($part_no){
        GLOBAL $struct;
        $part_no_split = split(".",$part_no);
        foreach($part_no_split as $k){
                $k = $k-1;
                $partstring .= "->parts[$k]";
        }
        eval("\$subtype = \$struct . \$partstring . "->subtype";");
        print "$subtype<br>\n";
}

$struct=imap_fetchstructure($mbox,$msg_nr);

$i=1;
while(imap_fetchbody($mbox,$msg_nr,$i)){
        GetStruct($i);
        $i++;
}
?>
-----------------------------------------------------
I'm down to the point where
print "$subtype<br>\n";
displays:

Object->parts[0]->subtype
Object->parts[1]->subtype
Object->parts[2]->subtype

onto the website page. How can I get PHP to
take it literally and show me the value of "subtype"?

Posted: Fri Jan 16, 2004 4:00 pm
by Thyme3333
bump :P