Home>Article>Backend Development> PHP uses the fgets() function to read the string line by line and then uses the explode() function to split the string into array instances.

PHP uses the fgets() function to read the string line by line and then uses the explode() function to split the string into array instances.

怪我咯
怪我咯 Original
2017-07-11 10:28:32 2268browse

fgets()FunctionRead a line from the file pointer. Theexplode() function breaks up thestringinto anarray.

The following example code first uses the fgets() function to read the string line by line and then uses the explode() function to split the string into an array. The code is as follows

"; $str = explode("|",$line); //print_r($str); $file_type = $str [0]; $dir_name = $str [1]; $file_name = $str [2]; $file_size = $str [3]; $create_time = $str [4]; echo $file_type; echo "
"; echo $dir_name; echo "
"; echo $file_name; echo "
"; echo $file_size; echo "
"; echo $create_time; echo "
"; } fclose($f); ?>

The above is the detailed content of PHP uses the fgets() function to read the string line by line and then uses the explode() function to split the string into array instances.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn