Loading files into an array in PHP _php tutorial

Source: Internet
Author: User
Use the file () function to load the files into an array, each line of the file as an element of the array.

Instance:
array_file.php:

View Sourceprint? 01. 02. $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];03.?>04.05. 06. Test Array File07. 08. 09. 10. $peoples = file($DOCUMENT_ROOT.'/test/03/people.txt');11. $count = count($peoples);12. if ($count == 0) {13. echo 'NO peoples pending. Please try again later.';14. }15. for ($i = 0; $i < $count; $i++) {16. echo $peoples[$i].'
'
;17. }18. ?>19. 20.

http://www.bkjia.com/PHPjc/371695.html www.bkjia.com true http://www.bkjia.com/PHPjc/371695.html techarticle use the file () function to load the files into an array, each line of the file as an element of the array. Example: Array_file.php:view sourceprint? php 02. $DOCUMENT _root = $_server [' ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.