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.
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    269
    Thanks
    39
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by patryk View Post
    i do have a question tho.
    if 'Welcome_to_FTSC_Website-999999.jpg' always stays the same, then why search for it?

    instead of first foreach loop you could just set your array
    PHP Code:
    $output[] = array('basename' => 'Welcome_to_FTSC_Website-999999.jpg',
                            
    // 'dirname' => $_SERVER['DOCUMENT_ROOT'] . '/images/slide-info-bg',
                            
    'date' => 999999
                             
    ); 
    Because that file is in that directory and it could be the middle file in the list, the top or the bottom. But when I display it to the public I want it to the first all the time and the rest shuffled.

    also if you are not using dirname in the rest of your code then you can just comment it out. you don't need it in array anyways
    the less code you have, the easier it is to find bugs afterwards
    True, true! This is rather funny because a co-worker and myself were just making comments about the programmers at work that leave all this displays in their programs to show dates and other misc items. Granted this is mainframe operations and the public would never see such a thing but for the love of Pete it clutters up my command terminal! I totally get your point!
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs

  2. #17
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    Quote Originally Posted by MrBiggZ View Post
    Because that file is in that directory and it could be the middle file in the list, the top or the bottom. But when I display it to the public I want it to the first all the time and the rest shuffled.
    yeah but if you preplace first foreach() loop with code i gave you, that's exactly what you will get.

    second loop just add's successive elements to your output array ignoring Welcome_to_FTSC_Website-999999.jpg anyways

  3. #18
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    269
    Thanks
    39
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by patryk View Post
    yeah but if you preplace first foreach() loop with code i gave you, that's exactly what you will get.

    second loop just add's successive elements to your output array ignoring Welcome_to_FTSC_Website-999999.jpg anyways
    Durr, yeah .. I got you now! I see what your're getting at!

    Back to stimulant!
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs

  4. #19
    Banned
    Join Date
    Apr 2013
    Location
    INDIA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use this coding it will help you

    $files = glob('/var/www/*');
    $firsFileToOutput = 'index.php';

    foreach($files as $value){
    if(is_file($value)){
    if(basename($value) == $firsFileToOutput){
    ///stuff to do with first file
    echo basename($value) . '<br />';
    }
    }
    }

    //randomize
    shuffle($files);

    foreach($files as $value){
    if(is_file($value)){
    if(basename($value) != $firsFileToOutput){
    ///stuff to do with every other file
    echo basename($value) . '<br />';
    }
    }
    }

  5. #20
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    @rowlandvictor

    serously....


 
Page 2 of 2 FirstFirst 12

Posting Permissions

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