Skip to content

Instantly share code, notes, and snippets.

@raplas
Last active February 27, 2017 16:45
Show Gist options
  • Save raplas/3268916da02ce00b259b20c1cb7bff02 to your computer and use it in GitHub Desktop.
Save raplas/3268916da02ce00b259b20c1cb7bff02 to your computer and use it in GitHub Desktop.
<?php
class Introduce {
private $arraylist = array();
public function regist($num) {
$this->arraylist[] = $num;
}
public function show() {
for ($i=0; $i<count($this->arraylist); $i++) {
if ($i%2 == 0) {
echo $this->arraylist[$i][0] . ":" . $this->arraylist[$i][1] . "\n";
}
else {
echo "奇数は出力しません。\n";
}
}
}
}
$obj = new Introduce();
$obj->regist(array("鈴木","熊本出身です。"));
$obj->regist(array("佐藤","東京出身です。"));
$obj->regist(array("工藤","宮崎出身です。"));
$obj->regist(array("宮本","愛知出身です。"));
<?php
require_once("0228class.php");
public function main(){
print $obj->show();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment