ahvahsky2008 Posted June 15, 2014 Report Share Posted June 15, 2014 (edited) Нужно в строке где первый столбец == "name1" поменять yes на no. файл db.txt. name1|1@mail.ru|name2|yes name3|2@mail.ru|name3|yes name4|3@mail.ru|name4|yes $glob = "name1"; $data = file('db.txt'); foreach ($data as $row) { $cols = explode('|', $row); if (strcmp($glob, $cols[0]) === 0) { $cols[3] = str_replace("yes", "no", $cols[3]); $row = implode('|', $cols); } }file_put_contents('1.txt', $data); Вроде и в цикл заходиьт, но данные такие же. НЕ меняет yes на no Edited June 15, 2014 by ahvahsky2008 Quote Link to comment Share on other sites More sharing options...
paxadm Posted June 16, 2014 Report Share Posted June 16, 2014 Так ты массив $data не изменяешь. Добавь в цикл: $newData[] = $row; и в конце соответственно file_put_contents('1.txt', $newData); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.