Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 获取引号中的文本
我有一个字符串 ["xx.xx.xx.xx"] 我希望它只返回引号内的内容。
您可以将正则表达式与捕获组一起使用:
if (preg_match('/\["(.*?)"\]/', '["xx.xx.xx.xx"]', $matches)) { echo $matches[1]; }