php实例之将文件读入到php数组中
|
php实例之将文件读入到php数组中,源代码如下: saveme.txt文件内容如下: a@example.com|Alice b@example.org|Bill c@example.com|Charlie d@example.com|Lewis php读取文件到数组: $file= file( 'saveme.txt' ); $file_array=array(); /* http://www.manongjc.com/article/1355.html */ while ( list( $line_num,$line ) = each( $file ) ) : $file_array[]=htmlspecialchars( $line ); endwhile; print_r($file_array); ?> 运行结果: Array ( [0] => a@example.com|Alice [1] => b@example.org|Bill [2] => c@example.com|Charlie [3] => d@example.com|Lewis ) (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
