Php unset() method is used to delete the variable. when you unset the variable then variable is deleted and it release the occupied memory by the variable.
unset() method is used to delete the array element and object property also.
<?php unset($variable_name); ?>
Example:- Suppose, You have an employee_name variable and you unset this variable and after that print, this variable then shows the Undefined variable: employee_name.
<?php $employee_name="John"; unset($employee_name); echo $employee_name; ?>
Delete the Array element through unset() method
If you want to delete the array then use unset() method.
<?php unset($array_element); ?>
Example:- Suppose, You have an emp_arr array and you want to unset this array element which is on zero position then use unset() method.
<?php $emp_arr=array("John","Tom","Mathew"); unset($emp_arr); print_r($emp_arr); ?>