教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php数组过滤重置键名功能

php数组过滤重置键名功能

发布时间:2016-10-26   编辑:jiaochengji.com
教程集为您提供php数组过滤重置键名功能等资源,欢迎您收藏本站,我们将为您提供最新的php数组过滤重置键名功能资源
使用array_filter函数可以过滤掉键值为空的元素,数组键名不变。如果想要过滤后的键名重新从0开始,可以使用array_values函数。
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6081')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6081>

<?php
$imgurl_str="||http://www.jiaochengji.com|http://www.jiaochengji.com|http://www.jiaochengji.com";
$imgurl_arr = explode ( "|", $imgurl_str );
$imgurl_arr =array_filter($imgurl_arr);
print_r($imgurl_arr);
$imgurl_arr = array_values($imgurl_arr);
print_r($imgurl_arr);
/*

Array

(

    
[2] => http://www.jiaochengji.com

    
[3] => http://www.jiaochengji.com

    
[4] => http://www.jiaochengji.com

)

Array

(

    
[0] => http://www.jiaochengji.com

    
[1] => http://www.jiaochengji.com

    
[2] => http://www.jiaochengji.com

)

*/

?>

您可能感兴趣的文章:
php数组过滤重置键名功能
php filter安全字符过滤
如何巧用 PHP 数组函数
PHP 过滤器Filter用法详解
php过滤html中网站链接 php实现域名白名单功能
PHP如何使用filter_id()函数获取过滤器ID?(代码示例)
一些php数组的学习入门笔记
php数组操作方法大全
PHP删除数组中空值
php数组回调过滤函数array_filter()的应用实例

[关闭]
~ ~