2
I have a TXT file that contains several different records, in some cases I need to get the information that is between 2 strings, e.g.: Cliente: FULANO DE TAL CPF:
I need what this between Cliente: e CPF:
.
In other parts of the same document I need to take the first 12 characters of a line after the string Tipo_OS:
if there is any information after the Tipo_OS:
and before another string also fixed in the document, as there may or may not be data between these strings.
obs. I don’t have a default separator character to generate my arrays, I could use :
, but some data are not after the :
and yes at the line below or after other data from the line below.
I know it sounds a little confusing, but what I’ve accomplished is this: found a function on the internet that allows me to pick values between 2 strings.
function GetBetween($var1="",$var2="",$pool){
$temp1 = strpos($pool,$var1)+strlen($var1);
$result = substr($pool,$temp1,strlen($pool));
$dd=strpos($result,$var2);
if($dd == 0){
$dd = strlen($result);
}
return substr($result,0,$dd);
}
It is even functional, but in the echo
continues to appear the other document data excluding the display only the string you set as initial and final.
Initially what I need would be the following, find a value between 2 strings and display only it, but I want to define several values between 2 strings until capturing all information of this service order, after I capture everything I need to run a while
to check if there are more things in the next pages, thus assembling my database with the orders of services contained in this document. Every time the document reads Cliente:
he identify that is the beginning of a new record.
You can put an example of the file
.txt
?– Sergio
In this model below are 3 Service Order.
– Ðracø
It exceeded the size, I will put only 2 records
– Ðracø
I’ll upload the file... I can’t paste the whole file.. exceeds the size
– Ðracø
Follow . txt file link in Mediafire
– Ðracø
https://www.mediafire.com/? 1pvi6p2ag92s7o
– Ðracø
Did Visualize Sergio?
– Ðracø
You know why they created xml and json ?
– Edilson
So Edilson, this question was a little pointless... If you have something to add to help a brother in trouble I am grateful!! Does this type of comment help at all... Is there anything I can do with Json or XML that will help me in my conversion from TXT to MYSQL??? Thanks for the help !!!
– Ðracø