2

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];
    }
}
?>
4

1 に答える 1

2

なぜ大騒ぎするのですか?

preg_match('/request_context.base_path: (.*)/', $lines[$x], $matches);
于 2012-08-20T12:26:41.320 に答える