Need help getting PHP to translate string as variable
Posted: Wed Jan 14, 2004 1:29 pm
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"?