是否有一个 PHP 函数可以提取字符串中两个不同字符之间的短语?像 substr()
;
例子:
$String = "[modid=256]";
$First = "=";
$Second = "]";
$id = substr($string, $First, $Second);
因此 $id
将是 256
任何帮助将不胜感激:)
最佳答案
使用此代码
$input = "[modid=256]";
preg_match('~=(.*?)]~', $input, $output);
echo $output[1]; // 256
关于php - 提取字符串中两个字符之间的子字符串 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14891743/