php 对数组按照字符串长度排序
$file = file('zong.txt'); usort($file, 'sortByLen'); $handle = fopen('zong2.txt', 'a'); foreach ($file as $v){ fwrite($handle, $v); } fclose($handle); function sortByLen($a, $b) { if (strlen($a) == strlen($b)) { return 0; } else { return (strlen($a) > strlen($b)) ? 1 : -1; } }