/    Sign up×
Community /Pin to ProfileBookmark

Read and modify the content of a txt file

Hello
I am trying to make a script that will read a .txt file and it will export the text that is written in the file in separate variables
I have emended an example to see.
I will try to describe the file but will be better if you have the time to open it.

The text is written in the same order in each txt file. The problem is the text length will be indefinable.

And something else the txt file is an export from a ERP system so I can’t modify the text. I have to deal it as it is.

If you have any idea please HELP

[upl-file uuid=7bb46fa2-cdcc-44fd-9a88-8749edd5bdc3 size=921B]orders3.txt[/upl-file]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@MrCoderMar 14.2007 — [code=php]
<?php
$lines = file("orders3.txt");

foreach($lines as $line)
{
$data = explode(",", preg_replace("/[ |t]{1,}/", ",", $line));

var_dump($data);
}
?>
[/code]


Untested, but I'm sure you get the idea.
×

Success!

Help @spyros spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...