$a=‘331612_1,331495_1,331461_2,331559_1,333080_1,333555_1,331448_1,331618_1,333388_1,333408_1,327937_1,331615_1,331499_1’;
怎么获取_后面的数字,并且将字符串_后面的数字相加。
`<?php
header(‘content-type:text/html;charset=utf-8’);
$a=‘331612_1,331495_1,331461_2,331559_1,333080_1,333555_1,331448_1,331618_1,333388_1,333408_1,327937_1,331615_1,331499_1’;
s
t
r
=
e
x
p
l
o
d
e
(
′
,
′
,
str = explode(',',
str=explode(′,′,a);
// print_r($str);
s
u
m
=
0
;
f
o
r
e
a
c
h
(
sum = 0; foreach (
sum=0;foreach(str as KaTeX parse error: Expected '}', got 'EOF' at end of input: …){ // print_r(v);
w
e
i
z
h
i
=
s
t
r
p
o
s
(
weizhi = strpos(
weizhi=strpos(v,’_’);
// echo $weizhi;
n
u
m
=
s
u
b
s
t
r
(
num = substr(
num=substr(v,$weizhi+1);
s
u
m
+
=
sum +=
sum+=num;
// echo $num;
}
echo $sum;`