php unset删除数组变量实现方法
要删除数据与变量在php中利用工作之便unset就可以实现了,当然也可以利用空也处理,不过销毁变量,让php变量在内存中消失哦。
要删除数据与变量在php教程中利用工作之便unset就可以实现了,当然也可以利用空也处理,不过销毁变量,让php变量在内存中消失哦。
*/
$array = array('aa'=>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,'aa'));
/*
unset();
该函数允许取消一个数组中的键名。要注意数组将不会重建索引。
$a = array( 1 => 'one', 2 => 'two', 3 => 'three' );
unset( $a[2] );
/* 将产生一个数组,定义为
$a = array( 1=>'one', 3=>'three');
而不是
$a = array( 1 => 'one', 2 => 'three');
清空整个数组
unset($arr);
4:清空指定元素
unset($arr[index]);
unset() 销毁指定的变量。注意在php 3 中,unset() 将返回true(实际上是整型值1),
而在php 4 中,unset() 不再是一个真正的函数:它现在是一个语句

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6
Visual web development tools