php实现数组首字符过滤功能代码
内容摘要
这篇文章主要为大家详细介绍了php实现数组首字符过滤功能代码,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随php教程的小玲来看看吧!
代码如下:
<?php
感兴趣的小伙伴,下面一起跟随php教程的小玲来看看吧!
代码如下:
<?php
文章正文
这篇文章主要为大家详细介绍了php实现数组首字符过滤功能代码,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随php教程的小玲来看看吧!
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <code class = "language-php" ><?php /* php教程 www.512Pic.com */ $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 </code> |
注:关于php实现数组首字符过滤功能代码的内容就先介绍到这里,更多相关文章的可以留意
代码注释