PHP を使用して、次のタスクを実行しようとしています。
1) 入力ファイルを読み取ります。
// some lines
request_context.base_path: /~test1/test2/web/
// some lines
2) 次の出力を取得します。
/~test1/test2/web/
これは私のコードですが、機能しません。
何か案は?ありがとう。
<?php
$lines = file('app/parameter.conf');
$l_count = count($lines);
for($x = 0; $x< $l_count; $x++)
{
if (strpos($lines[$x],'request_context.base_path:') !== false) {
preg_match('(request_context.base_path:)(\s.*)', $lines[$x], $matches);
echo $matches[1];
}
}
?>