如何在文本文件中编辑行的分割值?

问题描述

我有一个文本文件,其中包含1行带有此设置:

  • 2222; 3333

; 划分的两个值。

我如何编辑"splitted[0]""splitted[1]"并将新值保存在文件中?

以下是我到目前为止所拥有的:

<?php
$file_handle = fopen("mytext.txt","rw");
while (!feof($file_handle) )
{
    $line_of_text = fgets($file_handle);
    $parts = explode("\n",$line_of_text);

    foreach ($parts as $str)
    {
        $str_parts = explode(';',$str); // Split string by ; into an array
        array_shift($str_parts); // Remove first element
        echo current($str_parts)."\n"; // echo current element and newline
        // Same as $str_parts[0]
    }
}
fclose($file_handle);
?>

解决方法

getSupportActionBar().show();

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...