Translate

Monday, May 11, 2015

How to Delete an element from an array?





In this post, we will answer the question : How to Delete an element from an array?

First of all , we  will create our own array called :$aFruits


  
   $aFruits = array('apple','lemon','grapes','pineapple');
 

Secondly,  if we want to delete the lemon element, we have to use the function called unset and we need to access to  that element by  its  position number.


  
  unset($aFruits[1]);
 

Ouput:
 Array ( [0] => apple [2] => grapes [3] => pineapple )

No comments:

Post a Comment