Created
February 23, 2018 07:08
-
-
Save picasso250/3cccb88fcaee85aa3e95cbf52ee2aee0 to your computer and use it in GitHub Desktop.
get first line of file content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_first_line($content) { | |
$pos = -1; | |
do { | |
$pos = strpos($content, "\n", $pos+1); | |
$found = trim(substr($content, 0, $pos)); | |
// http://blog.sina.com.cn/s/blog_49f914ab0101eyjj.html | |
} while (trim(substr($content, 0, $pos), "\r\n\t \xEF\xBB\xBF") === ""); | |
return substr($content, 0, $pos); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment