gpt4 book ai didi

php - 使用 php 获取括号中包含的值

转载 作者:行者123 更新时间:2023-12-04 07:06:31 26 4
gpt4 key购买 nike

例如
字符串是我的名字是 xyz(25)
我想通过 php 在变量中获得 25 ..

最佳答案

使用 preg_match 来做到这一点:

$string = "xyz(25)";
preg_match("/.*\((\d*)\)/", $string, $matches);
print_r($matches);

将返回

大批
(
[0] => xyz(25)
[1] => 25
)

关于php - 使用 php 获取括号中包含的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1042625/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com