从字符串中提取单个(无符号)整数 [英] Extract a single (unsigned) integer from a string
本文介绍了从字符串中提取单个(无符号)整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从包含数字和字母的字符串中提取数字:
I want to extract the digits from a string that contains numbers and letters like:
"In My Cart : 11 items"
我要提取数字11
.
推荐答案
$str = 'In My Cart : 11 12 items';
preg_match_all('!\d+!', $str, $matches);
print_r($matches);
这篇关于从字符串中提取单个(无符号)整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文