+ Reply to Thread
Results 1 to 3 of 3

Thread: PHP Max Function Help

  1. #1
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    PHP Max Function Help

    PHP Code:
    <?php
    if (!defined('ROOT'))
        die;

    function 
    createGalleryDirectories() {
       
    $path ROOT.'gallery/events';
       
    $dir_handle = @opendir($path) or die("Unable to open $path");
       
    $count "0";
       while (
    $file readdir($dir_handle)) {
          if (
    $file!="." && $file!="..") {
             
    $galleryDirectory[$count] = $file;
             
    $count++;
          }
       }
       
    closedir($dir_handle);
       
       
    $i "0";
       while (
    $i $count) {
          list(
    $oldCaption$year$order) = explode("-"$galleryDirectory[$i]);
          
    $caption["$year"][$order] = str_replace("_"" ""$oldCaption");
          
    /*
          list($oldCaption[$i], $year[$i], $order[$i]) = explode("-", $galleryDirectory[$i]);
          $caption[$i] = str_replace("_", " ", "$oldCaption[$i]");
          */
          
    $i++;
       }
       
       
    /*
       $ii = "0";
       $numYears = count($caption);
       while ($ii < $numYears) {
          $year = max($caption);
          $html .= "<fieldset class=\"gallery\">";
          $html .= "<legend class=\"gallery\">$year</legend>";
       }
       */
       
       /*
       $ii = "0";
       $iii = "0";
       $yearDB = array();
       while ($ii < $count) {
          if (!in_array($year[$ii], $yearDB)) {
             $yearDB[$iii] = $year[$ii];
             $ii++;
             $iii++;
          } else {
             $ii++;
          }
       }
       */
       
       
       
    echo $count;
       echo 
    "<br />";
       echo 
    $i;
       echo 
    "<br />";
       echo 
    count($caption);
       echo 
    "<br />";
       echo 
    $caption;
       echo 
    "<br />";
       echo 
    $year;
       echo 
    "<br />";
       echo 
    $caption['2009'];
       echo 
    "<br />";
       echo 
    max($caption);
    //echo $html;
    }
    ?> 
    <!--
    <fieldset class="gallery">
    <legend class="gallery">2009</legend>
    <div class="row">          
       <div class="cell"><a href=""><img src="events/Marlboro_Day-2009/picture0.jpg" /></a><div class="caption">Marlboro Day</div></div>
       <div class="cell"><a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a></div>
    </div>
    </fieldset>
    -->
    gives me:
    Code:
    3
    3
    2
    Array
    2009
    Array
    Array
    how do I get the max function to display "2009" rather than Array?
    btw the file directory is in the attachments.
    Attached Thumbnails Attached Thumbnails PHP Max Function Help-help.jpg  

  2. #2
    zapzack is offline x10 Elder zapzack is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    606

    Re: PHP Max Function Help

    can you do
    Code:
    echo print_r(max($caption));
    Last edited by zapzack; 07-22-2009 at 05:37 PM.

  3. #3
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: PHP Max Function Help

    actually I already fixed it.
    PHP Code:
    $maxYear max(array_keys($caption)); 
    credit

+ Reply to Thread

Similar Threads

  1. [PHP] Basics of PHP Scripting
    By jeeter in forum Tutorials
    Replies: 21
    Last Post: 02-03-2010, 04:29 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. PHP Function Disabled???
    By stsights in forum Free Hosting
    Replies: 3
    Last Post: 09-14-2008, 11:53 AM
  4. PHP mail function
    By tearsfall in forum Free Hosting
    Replies: 2
    Last Post: 05-09-2008, 08:58 AM
  5. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers