简体   繁体   English

PHP preg_match_all返回空数组

[英]PHP preg_match_all returns empty arrays

I have this preg_match_all : 我有这个preg_match_all

$cash = "hi £240";

preg_match_all("/^£?(([1-9]{1,3}(,\d{3})*(\.\d{2})?)|(0\.[1-9]\d)|(0\.0[1-9]))$/", $cash, $matches);

print_r($matches);

And the print_r returns: 并且print_r返回:

Array ( [0] => Array ( ) [1] => Array ( ) [2] => Array ( ) [3] => Array ( ) [4] => Array ( ) [5] => Array ( ) [6] => Array ( ) ) Array([0] => Array()[1] => Array()[2] => Array()[3] => Array()[4] => Array()[5] => Array() [6] =>数组()

When I tried just preg_match, it didnt work at all, did I miss something? 当我尝试preg_match时,它根本不起作用,我错过了什么吗?

I am searching the string for GB monetary values. 我正在搜索字符串以获取GB货币值。

$cash = "hi £240";
preg_match_all("/£(?P<amount>\d*,?\d*\.?\d*)/",$cash,$match);

print_r($match['amount']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM