Home > Backend Development > PHP Tutorial > Array first character filter function code in php_PHP tutorial

Array first character filter function code in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:17:11
Original
933 people have browsed it

Copy code The code is as follows:

$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]);

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

Another: This code was found A strange problem: problems occur when using ',' (comma) as the delimiter.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325796.htmlTechArticleCopy the code as follows: ?php $array = array( 'abcd', 'abcde', 'bcde', 'cdef', 'defg', 'defgh' ); $str = '~'.implode('~',$array).'~'; $word = $_GET['word']; //url = xxx .php?word=...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template