gongzhonghao.png
扫码关注我们
最新赞助活动温馨提示:自愿赞助服务器费用,学生和没有工作的整站资源免费下载!
头像

php 对数组首字符过滤功能示例代码

来源:http://erdangjiade.com/topic/2079.html 你好,世界。 2017-09-25 22:42浏览(10)

php数组中需要对数组按首字符过滤,通过下面的代码实现了,需要的朋友可以参考下

代码如下:

<?php 
$array = array( 
'abcd', 
'abcde', 
'bcde', 
'cdef', 
'defg', 
'defgh' 
); 
$str = '~'.implode('~',$array).'~'; 
$word = $_GET['word']; //url = xxx.php?word=a 
preg_match_all("/~({$word}(?:[^~]*))/i",$str,$matches); 
var_dump($matches[1]); 

//输出 
//array(2) { [0]=> string(4) "abcd" [1]=> string(5) "abcde" } 
//End_php

以上就是php 对数组首字符过滤功能示例代码的详细内容,更多请关注二当家的素材网其它相关文章!

评论0
头像

友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群

1 2