Why $count -1

hi all

using this code to multi delete items.


$selcheckbox=array();   
$selcheckbox=$_REQUEST['item'];   
$count=count($selcheckbox);    
for($i=0;$i<$count-1;$i++) {      
$del_id = $selcheckbox[$i];          
$qry2 = "delete FROM table ......";
}

it works fine but i want to know why it is using $count-1


$i<$count-1

vineet

Simple but fundamental. Arrays are zero based by default.

So your count might be 3 items, but they are accessed with the keys 0,1,2

Hence to access the first item (1) it is $count -1 (0).

hi cups

thanks for the explanation

vineet