2016-11-17 107 views

回答

0

的第二部分试试这个代码:

$string = 'This is my string that conteined a Code:XYZ123'; 
$code = substr($string ,strpos($string,'Code:')); 
echo $code; 

确保这对您有帮助。

+0

未定义的变量:代码 –

+0

输出到这是'代码:XYZ123' – Blinkydamo

+0

PLZ再试一次我已经更新我的代码 –

1

您需要的起始位置“代码:”加长度“代码:”

$string = 'This is my string that conteined a Code:XYZ123'; 
$code = substr($string, strpos($string,'Code:') + 5); 
echo $code; //XYZ123 
1

另一种选择是爆炸串我Code:和回声阵列

$code = explode('Code:', $string); 
echo $code[ 1 ]