使用類別來對二維數組進行輸出應該怎麼做?
<?php
類別示範{
protected $name;
protected $age;
protected $wages;
公用函數__construct($name,$age,$wages){
$this->name = $name;
$this- >age = $age;
$this->wages = $wages;
}
public function show() {
return "員工的姓名是:{$this->name} 年齡:{$this->age} 薪水:{$this->wages}";
}
}
## $obj = new demo('peter',24,5000);
echo $obj-> show();
echo '
';
# $arr = array(array('name'=>'jike ','年齡'=>18,'工資'=>'500'),
array('姓名'=>'吉克','年齡'=>18,'工資' =>'500'),);
# foreach ($arr as $key => $value) {
if(is_array($value)){
foreach ($value as $key => $v) {
echo $key.'-'.$v.'
';
}
}
## }
#?>
哥特2427 天前1222