从php

时间:2015-10-10 12:49:36

标签: php

我有一个字符串$string = 'contact['.'firstname'.']';

如何从该字符串中获取contactfirstname

对我的英语很抱歉,很难描述这个问题

2 个答案:

答案 0 :(得分:1)

使用explode

$result = explode(chr(91),substr($string,0,-1));

然后$result[0]$result[1]将拥有您想要的内容

答案 1 :(得分:1)

<?php
$string = 'contact['.'firstname'.']';
$a = explode('[',substr($string,0,-1));
echo $a[0];
echo '<br />';
echo $a[1];
?>
相关问题