Online, etc., urgent. PHP replaces the string at the specified location
$a = ' 36,0.00,0.00,100|37,0.00,0.00,100|38,0.00,0.00,100|39,0.00,0.00,100 ';
$b = ' 38 ';
$c = ' 85 ';
How to do a replacement with PHP ...
This means that when $ A contains the number of words in $b. Replace 100 in 38,0.00,0.00,100 with the number in the $c.
If $b= ' 37 '
Then replace the 100 in 37,0.00,0.00,100 with the number in the $c.
Thank you, everyone.
------to solve the idea----------------------
php5.3+ through
$a = ' 36,0.00,0.00,100
------to solve the idea----------------------
37,0.00,0.00,100
------to solve the idea----------------------
38,0.00,0.00,100
------to solve the idea----------------------
39,0.00,0.00,100 ';
$b = ' 38 ';
$c = ' 85 ';
echo Preg_replace_callback ("/(^
------to solve the idea----------------------
\
------to solve the idea----------------------
$b, 0.00,0.00,) 100/", function ($m) use ($c) {return $m [1]. $c;}, $a);
36,0.00,0.00,100
------to solve the idea----------------------
37,0.00,0.00,100
------to solve the idea----------------------
38,0.00,0.00,85
------to solve the idea----------------------
39,0.00,0.00,100