The directory contains the directory a.logand B .txt. the source a.logsource file B .txt is written in php, And the content in the source file is output to. log content: 1.1 ^ A1452773009204 ^ B14670348 ^ cm_2000071003_21540... assume that the directory contains. log and B .txt
A. log source file
B .txt target file
The script is written in php to split the content in the source file into ^ A ^ B ^ C and output it to the target file.
The content in A. log is:
1.1 ^ A1452773009204 ^ B14670348 ^ cm_2000071003_21540002_21668001 ^ C ^ C15 ^ C ^ Bapp ^ C ^ C1: 201778e9036a8e37592c99441 ^ C ^ B1 ^ C56978e9036a8e37592c99441 ^ C1 ^ C ^ B ^ C ^ C1 ^ C0 ^ C ^ C0 ^ C ^ C48 ^ Bandroid ^ C ^ B ^ C ^ Ch5 ^ Bwifi ^ C ^ C10.62.50.235 ^ B ^ C ^ C1.0 ^ B ^ C ^ C ^ BMozilla/5.0 (Macintosh; intel Mac OS x 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36 ^ C ^ B ^ A ^ B
Hope you can advise
Reply content:
Assume that the directory contains A. log and B .txt texts.
A. log source file
B .txt target file
The script is written in php to split the content in the source file into ^ A ^ B ^ C and output it to the target file.
The content in A. log is:
1.1 ^ A1452773009204 ^ B14670348 ^ cm_2000071003_21540002_21668001 ^ C ^ C15 ^ C ^ Bapp ^ C ^ C1: 201778e9036a8e37592c99441 ^ C ^ B1 ^ C56978e9036a8e37592c99441 ^ C1 ^ C ^ B ^ C ^ C1 ^ C0 ^ C ^ C0 ^ C ^ C48 ^ Bandroid ^ C ^ B ^ C ^ Ch5 ^ Bwifi ^ C ^ C10.62.50.235 ^ B ^ C ^ C1.0 ^ B ^ C ^ C ^ BMozilla/5.0 (Macintosh; intel Mac OS x 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36 ^ C ^ B ^ A ^ B
Hope you can advise
Procedure
1. file_get_contents () Get the log source file content
2. preg_match_all () split the content into an array
3. Assemble your string in the desired format and add a line break or anything ~
4. file_put_contents () Output content to the txt file