string(5) "abcde" } //End_php 另:这段代码发现了一个奇怪的问题:分隔符使用','(逗号)的时候会出现问题。h">
时间:2021-07-01 10:21:17 帮助过:17人阅读
输出
$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]);
//
http://www.bkjia.com/PHPjc/325796.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/325796.htmlTechArticle 代码如下:?php $array = array( 'abcd', 'abcde', 'bcde', 'cdef', 'defg', 'defgh' ); $str = '~'.implode('~',$array).'~'; $word = $_GET['word']; //url = xxx.php?word=...