Results 1 to 6 of 6

Thread: Bug in function [Resolved]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Resolved Bug in function [Resolved]

    Hello all, i have a function that calcs what's the most repeated value in a string, that string has multiple values including separator chars, the problem is that the function doesn't work for values bigger then 9.
    The function "see's" 9 as one char and the value 10 is seen as 2 chars.

    PHP Code:

        
    function mode_of_values($mystring){
            
    $bigger=-1;
            
    $data $mystring;
            
    $result count_chars($data0);
            for (
    $i=0$i count($result); $i++)
            if ((
    chr($i)!=",") and (chr($i)!=";")){
               if (
    $result[$i] != 0)
                if(
    $bigger<$result[$i]){
                    
    $bigger=$result[$i];
                    
    $character=chr($i);
                }
               }
            }
            return 
    $bigger.",".$character;
        }

    mode_of_values("1,3,4;2,3,4;2,5,6;2,6,8");//this works just fine but not when i call like:
    mode_of_values("10,11,12;10,13,14;11,12,13"); 
    Any idea how to fix this?

    Thanks
    Last edited by TDQWERTY; May 28th, 2005 at 03:45 PM.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

Posting Permissions

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



Click Here to Expand Forum to Full Width