且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP从文本文件中获取价值

更新时间:2023-01-23 13:54:50

这应该可以满足您的需求,我已经在服务器上对其进行了测试,它似乎可以满足您的需求.

This should work with what you are looking for, I tested it on my server and it seems to fit what you are looking for.

$lines_array = file("file.txt");
$search_string = "bing";

foreach($lines_array as $line) {
    if(strpos($line, $search_string) !== false) {
        list(, $new_str) = explode(":", $line);
        // If you don't want the space before the word bong, uncomment the following line.
        //$new_str = trim($new_str);
    }
}

echo $new_str;

?>