2011-05-07 2 views
1

를 사용하여 텍스트 파일) ...은 (오름차순) 내가 natsort를 (사용하여 정렬 된 파일이 PHP

반전 그러나 실제로 나는 내림차순으로 정렬 할 문서의 마지막 라인은 내가 PHP에서 좋은 아니에요

.. 첫 번째 줄과 그 반대의 경우도 마찬가지

Pls는이를 실현하려 어떤 기능이나 조각이 알려 될 품질에 관계없이 모든 응답을 음미해야한다 ... 감사합니다.

+3

'file()'+'array_reverse()'+'implode()'+'file_put_contents()' – zerkms

+0

http://goo.gl/dX8QT –

답변

0

array_reverse는 ..., 다음과 같이 file, array_reversefile_put_contents이를 달성하기 위해 사용할 수있는 큰 텍스트 파일이 아닌 가장 효율적인 방법 동안 위해

$reverse = array_reverse($array, true); 
0

내림차순으로 내용을 줄 것이다

<?php 
    // Fetch each line from the file into an array 
    $fileLines = file('/path/to/text/file.txt'); 

    // Swap the order of the array 
    $invertedLines = array_reverse($fileLines); 

    // Write the data back to disk 
    file_put_contents('/path/to/write/new/file/to.txt', $invertedLines); 
?> 

... 당신이 겪은 것을 달성하십시오.