Home > Backend Development > PHP Tutorial > Detailed explanation of regular expression preg_grep function

Detailed explanation of regular expression preg_grep function

小云云
Release: 2023-03-22 11:22:02
Original
2011 people have browsed it

This article mainly shares with you the detailed explanation of the regular expression preg_grep function. preg_grep returns an array composed of elements matching the pattern pattern in the given array input. Hope it helps everyone.

##patternRegular expression Formula, pattern to be searched, string form.inputInput array.flagsIf set to PREG_GREP_INVERT, this function returns an array of elements in the input array that do not match the given pattern pattern.
$array = array(1.2, 1.3, 1, 11.1);$fl_array = preg_grep("/^(\d+)?\.\d+$/", $array);
var_dump($fl_array); //array(2) { [0]=> float(1.2) [1]=> float(1.3) }$fl_array = preg_grep("/^(\d+)?\.\d+$/", $array);
var_dump($fl_array); //array(1) { [2]=> int(1) }
Copy after login
Parameter Description
Related recommendations:


(PHP) Regular expression-preg_grep function usage

Example explains the use of PHP function preg_grep()_PHP tutorial

Example to explain the use of PHP function preg_grep()

The above is the detailed content of Detailed explanation of regular expression preg_grep function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template