Phpunset: How to delete array variables. To delete data and variables, you can use the unset function in php. of course, you can also use the null function to process them. However, you can destroy the variable so that the php variable disappears in the memory. To delete data, you need to delete the data and variables. in php, you can use the unset function. of course, you can also use the null function to process the data, but you can destroy the variables, let the php variable disappear in the memory.
To delete data and variables, you can use the unset function in the php Tutorial. of course, you can also use the null function. however, destroy the variable so that the php variable disappears in the memory.
*/
$ Array = array ('a' => 1, 'BB '=> 2 );
Function delete (& $ array, $ key)
{
If (! Is_array ($ key )){
$ Key = array ($ key );
}
Foreach ($ key as $ k ){
Unset ($ array [$ k]);
}
$ Array = array_values ($ array );
}
Print_r (array_values ($ array ));
Print_r (delete ($ array, 'A '));
/*
Unset ();
This function allows you to cancel the key name in an array. Note that the array will not rebuild the index.
$ A = array (1 => 'one', 2 => 'two', 3 => 'Three ');
Unset ($ a [2]);
/* Generates an array, defined
$ A = array (1 => 'one', 3 => 'Three ');
Instead
$ A = array (1 => 'one', 2 => 'Three ');
Clear the entire array
Unset ($ arr );
4: Clear the specified element
Unset ($ arr [index]);
Unset () destroys the specified variable. Note that in php 3, unset () returns true (actually an integer value of 1 ),
In php 4, unset () is no longer a real function: it is now a statement
Bytes. To delete data...