如何显示包含数组的地址的内容?
例子:
class ConferenceInfo {
var $confID;
var $confName;
var $divisons = array();
/* display an address in HTML */
function display() {
$output = '';
$output .= $this->confID;
$output .= $this->confName;
foreach($this->divisons as $value) { // I know this is incorrect
$output .= $value;
}
$output .= '<br/>';
return $output;
}
}
和 PHP 代码:
$conf = new ConferenceInfo;
$conf->confID = $someValue1;
$conf->confName = $someValue2;
$conf->divisons[] = $someValue3; // this will eventually loop and fill in multiple values
echo $conf->display();
数据示例为:
confID = 1<br/>
confName = Eastern<br/>
dvisions = Atlantic, Central, Northeast
预期的输出display()
将是:
1EasternAtlanticCentralNortheast