CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Jan 2006
    Posts
    352

    Bug in function, in_array()??

    So...
    This is user input:
    PHP Code:
     $range = array(2.5559.69); 
    This is parsed code:
    PHP Code:
     $okRange = array('min_range''max_range');
     
    foreach(
    $range as $k => $v)
    {
       if( 
    in_array($k$okRange) === false )
       {
         echo 
    "$k is invalid range flag!" NL;
       }

    Response is:
    HTML Code:
    1 is invalid range flag!
    But it was supposed to fail at: 0 is invalid range flag!
    Why did int(0), passed through?!?

    After I added a third param bool(true), to in_array(), then it worked like:
    PHP Code:
    ... if( in_array($k$okRangetrue) === false ) ... 
    Bit it still doesn't make sense, why did int(0), passed through without third param bool(true)?!?

    int(0), was compared to values 2.55 and 59.69.
    So it was supposed to fail, like int(1) does!
    Last edited by Ipsens; June 19th, 2008 at 10:54 AM.
    Ipsens

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

Featured