我想要像这样的所有字符串的总和1+2+3+4+5.
$input = '12345';
Run Code Online (Sandbox Code Playgroud)
你可以通过array_sumPHP 的功能来做到这一点.
$input = '1,2,3,4,5';
$res = explode(',',$input);
$result = array_sum($res);
echo $result;
Run Code Online (Sandbox Code Playgroud)