php - How to ignore lines based on specific statement in this function which reads the data from a text file? -
About the function information: Currently it takes the last 20 lines and based on the requested column Displays information from lines on
What do I have to do?
I want to ignore those rows whose columns consist of 5 and 13. Example: (Both lines should be ignored below, because the first row in column 5 corresponds to column 13 and the second row is the same as before because the first name of column 5 corresponds to the name of column 13).
1, 42.16, 201, Satkovrflo_ugr, 1, 6762160, 39799, 9817242, 6762160, 39884, 10010545, Satkovrflo_ugr, 2, 1351147, 1165, 483259, 1351147, 1115, 241 630, 0 L,46 , 27, 201, [stackoverflow_user | stackoverflow_userother], 1, 4,078,465, 286,991, 1,594,830, 4,078,465, 287,036, 1,643,156, stackoverflow_user, 2, 1,357,147, 1115, 241,630, 1,357,147, 1065, 120,815, 0
So, should additional script Grab the line and ignore the line that can display up to 20 valid lines until the column matches.
down my actual work:
function DMMRankings () {# a file into an array $ lines = file ( "C: /path/to/file.txt ', FILE_IGNORE_NEW_LINES; FILE_SKIP_EMPTY_LINES); # Take the last 20 rows of a file - that is, the last 20 values in the array $ last_ten = array_slice ($ rows, -20); # Create an array for output $ n = 1; $ Content = ''; Give foreign currency ($ last_ten $ l) {# values as values separated by commas $ arr = explosion (",", $ l); # If col 5 has multiple values, if first one takes preg_match ("/æ[(.+) \?? /", $ Arrivals [4], $ match)) {$ arrivals [4] = $ matches Is [1]; } #We want the data in an output array $ Data = array ( 'Rank-pause' = & gt; $ n ++, 'rank-name' = & gt; $ arr [4], 'rank-Dimughr' = & gt; $ arr [12]); $ Content = Template :: Load ('Ranking DM-'. ($ N% 2 == 1? 2: 1), $ data); } $ This- & gt; Content = Template :: Load ('user_rankingsdm', array ('ranking' => gt; $ content)); }
Please help me how I can do this on my current function. Thanks!
"itemprop =" text ">
For 20 valid lines, by just looping you remain 20.
$ lastline = count ($ lines); $ DSP = 0; (DSP <20) {// To check if there are any other lines (! $ Lines [$ lastline- $ dsp]) {echo, 'Oops, we left the lines; Break;} $ l = $ rows [$ lastline-$ dsp]; Treat $ data as comma-separated values as $ arr = explosion (",", $ l); # If col 5 has multiple values, if first one takes preg_match ("/æ[(.+) \?? /", $ Arrivals [4], $ match)) {$ arrivals [4] = $ matches Is [1]; } // if 5 = = 13 leave ($ arr [4] == $ arr [12]) Continue; // Other: add one to the counter of $ dsp ++; # We want data in an output array. $ Data = array ( 'Rank-pause' = & gt; $ n ++, 'rank-name' = & gt; $ arr [4], 'rank-Dimughr' = & gt; $ arr [12]); $ Content = Template :: Load ('Ranking DM-'. ($ N% 2 == 1? 2: 1), $ data); }
Comments
Post a Comment