【发布时间】:2014-07-21 14:08:13
【问题描述】:
$A=123132,32132,123132321321,3
$B=1,32,99
$C=456,98,89
$D=1
我想在第一个逗号后剪切字符串
输出。 . .
$A=123132
$B=1
$C=456
$D=1
【问题讨论】:
-
php.net 提供了很好的参考文档:php.net/manual/en/function.explode.php
$A=123132,32132,123132321321,3
$B=1,32,99
$C=456,98,89
$D=1
我想在第一个逗号后剪切字符串
输出。 . .
$A=123132
$B=1
$C=456
$D=1
【问题讨论】:
有很多方法可以做到这一点:
substr($A,0,strpos($A,","))
或
当前(爆炸(“,”,$A))
都将返回值123132
【讨论】:
$newA = current(explode(",", $A));
来自:PHP substring extraction. Get the string before the first '/' or the whole string
【讨论】:
你可以的
$A='123132,32132,123132321321,3';
$t=explode(',',$A);
$result = $t[0];
【讨论】: