Php解析从文本文件中提取数据

时间:2015-08-03 13:59:13

标签: php

我有以下文件,我想用php解析它然后提取数据,例如:pakage值是Oclbook,所以$var Oclbook应该在$var2

然后深入:客户应该在$var3 年龄应该是变量,> =应该在$var 4 18应该在$var 5等等......

$file_handle = fopen("oclbook.ocl", "rb");

while (!feof($file_handle) ) {

$line_of_text = fgets($file_handle);
$parts = explode('/n', $line_of_text);
$parts[1] = isset($parts[1]) ? $parts[1] : null;
print $parts[0] . $parts[1]. "<BR>";

}

fclose($file_handle);
package OclBook

context Customer
inv: age >= 18

context CustomerCard
inv: validFrom.isBefore(goodThru)


context LoyaltyProgram
inv: serviceLevel->size = 2

context Customer
inv: program->size = cards->select( valid = true )->size

context LoyaltyProgram
inv: partners.deliveredServices->forAll(
          pointsEarned = 0 and pointsBurned = 0 ) 
      implies membership.loyaltyAccount->isEmpty
--------------------------------------------

0 个答案:

没有答案