counting array

Discussion in 'PHP' started by nastynappy, Jan 28, 2008.

  1. #1
    can anyone please tell me what does this script do ??
    
    	if($child['cat_id'] != $child['cat_parent']) {
    	$count = count($child)-1;
    		for ($i = 0; $i < $count; $i++) {
    			if ($i == 0) {
    			$ii[] = $i;
    			}
    		}
    			
    			$iii = count($ii);
    			
    			if ($count == $iii) {
    		    $add = '&nbsp;&nbsp;';
    			}			
    			else {
    			$add = '|';
    			}
    			}
    
    PHP:
    please?
     
    nastynappy, Jan 28, 2008 IP
  2. CreativeClans

    CreativeClans Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    if($child['cat_id'] != $child['cat_parent']) {
       $count = count($child)-1;
       for ($i = 0; $i < $count; $i++) {
          if ($i == 0) {
             $ii[] = $i;
          }
       }
       $iii = count($ii);
       if ($count == $iii) {
          $add = '&nbsp;&nbsp;';
       }         
       else {
          $add = '|';
       }
    }
    PHP:
    Indented like this, it's a bit easier to read. But still, I have no idea what it's for :confused:
     
    CreativeClans, Jan 28, 2008 IP
  3. nastynappy

    nastynappy Banned

    Messages:
    499
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it is for counting the number of names echoed in <option> collected from mysql database's table.

    i can understand the first part, but not rest of it.
    i can see it is:
    if $child['cat_id'] isnt $child['cat_parent'] (which means, if the current echoed name isnt a parent) then do the rest of code.. which is the part i cant understand.
    so, can anyone help me ??
     
    nastynappy, Jan 28, 2008 IP