Home  >  Article  >  Backend Development  >  How to delete the entire array in php

How to delete the entire array in php

藏色散人
藏色散人Original
2021-03-08 10:35:282995browse

php method to delete the entire array: first create a PHP sample file; then define an array $a; finally delete the entire array through "unset($a);".

How to delete the entire array in php

#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.

For example:

$a=array(1,2,3);
unset($a);

The entire array can be deleted.

Deleting an array and clearing an array are not the same concept. After deleting an array, it is no longer accessible. In the above example, after we unset, the array no longer exists and the entire $a is inaccessible.

unset introduction:

unset - Release the given variable

Description

unset ( mixed $var , mixed $... = ? ) : void

unset() Destroys the specified variable.

The behavior of unset() in a function will vary depending on the type of variable you want to destroy.

If you unset() a global variable in a function, only the local variable will be destroyed, and the variables in the calling environment will maintain the same value before calling unset().

[Recommended: "PHP Video Tutorial"]

The above is the detailed content of How to delete the entire array in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn