SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Session Arrays and echo a complete single entry

    Good day to you all,
    I'm working around array and session and I was wondering how can I retrieve all array that are from level one.

    This array is a file array.

    I'm working with a multidimensional array.

    Here is my code :

    PHP Code:


    <?php

    session_start
    (); 

       function 
    recur_dir($dir)
       {
           
    $dirlist opendir($dir);
           while (
    $file readdir ($dirlist))
           {
               if (
    $file != '.' && $file != '..')
               {
                   
    $newpath $dir.'/'.$file;
                   
    $level explode('/',$newpath);
                   if (
    is_dir($newpath))
                   {
                       
    $mod_array[] = array(
                               
    'level'=>count($level)-1,
                               
    'path'=>$newpath,
                               
    'name'=>end($level),
                               
    'kind'=>'dir',
                               
    'mod_time'=>filemtime($newpath),
                               
    'content'=>recur_dir($newpath) );
                   }else{ 
                       
    $mod_array[] = array(
                               
    'level'=>count($level)-1,
                               
    'path'=>$newpath,
                               
    'name'=>end($level),
                               
    'kind'=>'file',
                               
    'mod_time'=>filemtime($newpath),
                               
    'size'=>filesize($newpath) );
                  }
               }
           }
           
    closedir($dirlist);
           
       
    ksort($mod_array);   

    $_SESSION['listimages']=$mod_array
       
           return 
    $mod_array;
       }
       
       echo 
    '<pre>';
       
    print_r(recur_dir('Art'));
       echo 
    '</pre>';
       
    ?>



    PHP Code:


    <?php
    session_start
    ();
    Print_r ($_SESSION);
    echo 
    "<p>";

    //echo a single entry from the array
    echo $_SESSION['listimages']['level'][2];
    ?>

    Thanks !

  2. #2
    SitePoint Evangelist priti's Avatar
    Join Date
    Aug 2006
    Location
    India
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    kindly provide your output for $_SESSION so one can help you to access it.


Bookmarks

Posting Permissions

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