亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何編輯文本文件中一行的分割值?

如何編輯文本文件中一行的分割值?

PHP
米琪卡哇伊 2023-09-22 16:52:45
我有一個文本文件,其中包含 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);?>
查看完整描述

1 回答

?
動漫人物

TA貢獻1815條經驗 獲得超10個贊

<?php


$file = '2222;3333'; // that is your file

$file = explode(';', $file); // This split your file with delimiter ";"


foreach ($file as $newFile) {

    // Do whatever you want

    var_dump($newFile);

}


查看完整回答
反對 回復 2023-09-22
  • 1 回答
  • 0 關注
  • 107 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號