Q:

Delete an element from the above array. After deleting the element, integer keys must be normalized

0

$x = array(1, 2, 3, 4, 5);
Delete an element from the above array. After deleting the element, integer keys must be normalized.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
 $x = array(1, 2, 3, 4, 5);
 var_dump($x);
 unset($x[3]);
 $x = array_values($x);
 echo '
';
var_dump($x);
?>

Sample Output:

array(5) {                                                  
  [0]=>                                                     
  int(1)                                                    
  [1]=>                                                     
  int(2)                                                    
  [2]=>                                                     
  int(3)                                                    
  [3]=>                                                     
  int(4)                                                    
  [4]=>                                                     
  int(5)                                                    
}                                                           
array(4) {                                                  
  [0]=>                                                     
  int(1)                                                    
  [1]=>                                                     
  int(2)                                                    
  [2]=> 
  int(3)                                                    
  [3]=>                                                     
  int(5)                                                    
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now