将逗号分隔的字符串转换为int PHP? [英] Convert a comma separated string to int PHP?
本文介绍了将逗号分隔的字符串转换为int PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以使用PHP将185,345,321转换为185345321吗?
Is there any way you can convert "185,345,321" to 185345321 by using PHP?
推荐答案
是的,有可能:
$str = "185,345,321";
$newStr = str_replace(',', '', $str); //If you want it to be "185345321"
$num = intval(@newStr); //If you want it to be a number 185345321
这篇关于将逗号分隔的字符串转换为int PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文