PHP Logical Interview Questions

 1. In an array entered value should not be print.  
     $n = 2;  
     $ar = array(1, 2, 3, 4, 5);  
     unset($ar[$n - 1]);  
     $arr = array();  
     $j = 0;  
     for ($i = 0; $i <= count($ar); $i++) {  
       if ($ar[$i] != '') {  
         $arr[$j] = $ar[$i];  
         echo $arr[$j] . '<br>';  
         $j++;  
       }  
     }  
 Output :   
 1  
 3  
 4  
 5  

Comments

Popular posts from this blog