PHP字符串在引用之间拆分

时间:2012-10-14 07:56:32

标签: php split

  

可能重复:
  Get text in quotes

我有一个字符串[“xx.xx.xx.xx”] 我希望它只返回引号内的内容。

1 个答案:

答案 0 :(得分:1)

您可以将正则表达式与捕获组一起使用:

if (preg_match('/\["(.*?)"\]/', '["xx.xx.xx.xx"]', $matches)) {
  echo $matches[1];
}
相关问题