首先我读取文件,如果该行包含function
关键字,我想读取功能块中的行。我的文件结构是
function some_method2() {
one;
}
function some_method3() {
two;
return;
}
答案 0 :(得分:0)
$obj = new SplFileObject('filename','r+');
while(!$obj->eof()){
$curr_line = $obj->current();
if(strpos($curr_line,"function" )!==false){
$obj->next();
while(strpos($obj->current(),'}')!== true)
{
$body .= $obj->current();
$obj->next();
}
}
else{
$obj->next();
}
}