am new to File function in php
I have a list in a txt file.. i wanna capture only alternative lines from the txt file.
Any suggestions. Thanx in advance
Thats an easy one.
$data = file( "file.txt" ); foreach( $data as $key => $value ) { if( $key % 2 == 1 ) // if you want the first line use 0 instead of 1 $newData[] = $value; }
HalfaBee;10888960 wrote:Thats an easy one. $data = file( "file.txt" ); foreach( $data as $key => $value ) { if( $key % 2 == 1 ) // if you want the first line use 0 instead of 1 $newData[] = $value; }
Thanx....it worked.... hey is there a way to delete double entries from an array...? 😕
Use http://au.php.net/manual/en/function.array-unique.php