Code: Select all
function readFile(){
$fd = fopen("guest.dat","r");
$i=0;
while(!feof($fd)){
$i++;
$name[] = trim(fgets($fd),255);
$comment[] = trim(fgets($fd),255);
$space[] = trim(fgets($fd),255);
}
fclose($fd);
}
function view(){
global $HTTP_GET_VARS;
$pageLength = 5;
$this->readFile();
if(isset($HTTP_GET_VARS["start"]) && is_numeric($HTTP_GET_VARS["start"])){
$mulai = $HTTP_GET_VARS["start"];
}else{
$start = 0;
}
for($i=$start; $i<$start+$pageLength&& $i<$this->readFile();$i++){
//Want to print the array from readFile
}
}But i want to separate my function, and i don't know how to call the name, comment and space in view function. I use
Code: Select all
echo $this->readFile().name[$i];feyd | hey look ma,
Code: Select all
is on. [/color]