网站制作学习网PHP→正文:php删除数组某个索引值
字体:

php删除数组某个索引值

PHP 2013/10/15 12:08:27  点击:不统计

http://www.forasp.cn/

原文是网站制作学习网的FoAsP.cn
 php可以通过unset删除数组中的值
举例 如果如果没有key的数组
$forasp = array(1,6,9);
var_export($forasp);
unset($forasp[0]);
var_export($forasp);
//输出结果
array (
  0 => 1,
  1 => 6,
  2 => 9,
)array (
  1 => 6,
  2 => 9,
)
如果有key的数组
$forasp = array("site"=>"forasp","name"=>"网站名");
var_export($forasp);
unset($forasp['site']);
var_export($forasp);
array (
  'site' => 'forasp',
  'name' => '网站名',
)array (
  'name' => '网站名',
)
这样就可以通过php unset 删除数组中的某个值

原载于:文章来源:www.forasp.cn网站制作学习

网站http://www.制forasp作.cn

·上一篇:php sleep 小于1秒 >>    ·下一篇:Cannot use output buffering in output buffering display handlers in >>
推荐文章
最新文章