Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    recursively read a dir and all files ( new to php )

    I have a php parser script that is working ok for single file parsing, but id like it to parse multipul file from a directory
    ( dir0/file1 dir0/file2 dir0/dir1/file1 dir0/dir1/file2 etc: ) i have tryed different things but to avale.

    here is the code that works for single file parsing.

    PHP Code:
    <?php
    include_once('simple_html_dom.php');

    $html file_get_html('1.html');

    $e $html->find('table'0)->find('pre'0); 
    $body ''
    foreach (
    $e as $element
    $body .= '' $element->plaintext ''
    $body .= ''
    $html str_get_html($body); 
    $html->save('result.htm');

    ?>
    here is a pice of code that i have tryed.

    PHP Code:
    <?php
    include_once('simple_html_dom.php');
     
    $strDir = ('D:\simplehtmldom\test');

    $html file_get_html ($strFile);
    $objHandle opendir($strDir);
    while((
    $strFile readdir($objHandle)))
    {
    if(
    $strFile != ".." && $strFile != ".")
    {

    $e $html->find('table'0)->find('pre'0); 
    $body ''
    foreach (
    $e as $element
    $body .= '' $element->plaintext ''
    $body .= ''
    $html str_get_html($body); 
    $html->save('$strDir.$strFile.txt');
    }
    }
    closedir($objHandle);

    ?>
    and thx inadvance for any help on this.

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    Here's a fairly simple scandir function that you can use
    http://lixlpixel.org/recursive_funct...irectory_scan/
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • Users who have thanked JAY6390 for this post:

    whitevamp (02-11-2010)

  • #3
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    just wanted to say thanks JAY6390 for the script link.
    it took me quite a wile trying to figure out how to get the two scripts to work together.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •