PHP正则获取字符串中数字

WBOY
Release: 2016-06-20 12:54:22
Original
715 people have browsed it

<?php    $patterns = "/\d+/"; //第一种    //$patterns = "/\d/";   //第二种    $strs="left:0px;top:202px;width:90px;height:30px";    preg_match_all($patterns,$strs,$arr);    print_r($arr);    /***************运行结果*********************/  //第一种Array(    [0] => Array        (            [0] => 0            [1] => 202            [2] => 90            [3] => 30        ))//第二种Array(    [0] => Array        (            [0] => 0            [1] => 2            [2] => 0            [3] => 2            [4] => 9            [5] => 0            [6] => 3            [7] => 0        ))
Copy after login

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!