Hi!
I need some help! I've inserted a text file into an array (about 2000 lines):
$lines = file ("1.TXT");
and i need to delete line 72 an 73...
Can somebody tell me how to do so??
THX!
you can open the file and read it line by line, while you are looping line by line make sure you started your counter next to it in the loop from the begening and put if condition in it. if line is 73 or 74 the conitue else add it in the variable.
this is easy to do it.
Since each element in the array can be accessed by $lines[line number] you can simply set each line to a blank ie $lines[52]="";
Don't forget the the first line is 0 so to delete line 53 you will need $lines[52]="".
Hi again!
This solution is just like
unset($lines[52]);
The thing is: i don't want the line emptied... i want it gone, deleted... ?!?
btw, can you also help me with this:
foreach ($lines as $i => $line) {......}
I want to count the caracters within $line, whitespaces incuded. I tried:
count_char($line)
but this only returns the text "Array"... 😕
Originally posted by abnfire you can open the file and read it line by line, while you are looping line by line make sure you started your counter next to it in the loop from the begening and put if condition in it. if line is 73 or 74 the conitue else add it in the variable. this is easy to do it.
how can read it line by line?
try...
count_char($line[52])