| 
	
 | 
 Posted by roN on 06/12/95 11:28 
Stefan Rybacki wrote: 
sorry didn't get that: 
>  
> The first problem is the weird filename format you're using 
> (...-05-09-13,14). The second day value doesn't help here ;) 
>  
> Ok try this regular expression 
>  
> /([^-]*)-([^.]*)\.jpg/i 
and what should I do with it? 
>  
> use a match all function and you will retrieve an array with the number 
> and the date seperated. Then change the compare function to first compare 
> the date and only if both dates are the same compare the number, thats 
> all. 
what do you mean with 'match all function' 
Ok, I've tried it like below, but doesn't really work, 
$rega[1] is always "" 
and in $rega[0] is the whole filename... :( 
[Code] 
function mycompare ($a, $b) 
{ 
        $rega=split("/([^-]*)-([^.]*)\.jpg/i",$a);//extract date and filename 
        $regb=split("/([^-]*)-([^.]*)\.jpg/i",$b);//extract date and filename 
        echo $rega[0]." [0]<br>\n"; 
        echo $rega[1]." [1]<br>\n"; 
         
        if($rega[1]==$regb[1]) //compare date 
          { 
          //first check for search text in $a and $b 
          $isInA=(strpos($a,'p')!==false); 
          $isInB=(strpos($b,'p')!==false); 
 
          //so if $isInA==$isInB then compare alphabetical 
          //but reverse first a & b 
          $a=strrev($a); 
          $b=strrev($b); 
          if ($isInA == $isInB) 
            { 
            if ($a == $b) 
              return 0; 
            return ($a > $b) ? 1 : -1; 
            } 
          else 
            { 
            //the one that is true comes first 
            return ($isInA) ? -1:1; 
            } 
 
          return 0; 
          } 
        else 
          { 
          return 0; 
          } 
} 
[/Code] 
Sorry, but I'm quite new to that stuff. 
--  
chEErs roN 
 
I'm root, I'm allowed to do this! ;) 
keep on rockin'
 
  
Navigation:
[Reply to this message] 
 |