Online, urgent. PHP replaces the string $ a & nbsp; 36, 0.00, 0.00, 100 | 37, 0.00, 0.00, 100 | 38, 0.00, 0.00, 100 | 39, 0.00, 0.00, 100; $ b38; $ c85; how can I replace it with PHP... & Nbsp; that is, & nbsp; after $ a contains the number of words in $ B. & Nbsp; put 38, online, etc., urgent. PHP replaces the string at the specified position
$ 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 replace it with PHP...
That is to say, when $ a contains the words in $ B. Replace 0.00 in 38, 0.00, 100, and 100 with a number in $ c.
If $ B = '37'
Replace 0.00 in 37, 0.00, 100, and 100 with a number in $ c.
Thank you!
------ Solution ----------------------
Through php5.3 +
$ A = '36, 0.00, 0.00, 100
------ Solution ----------------------
37, 0.00, 0.00, 100
------ Solution ----------------------
38, 0.00, 0.00, 100
------ Solution ----------------------
39, 0.00, 0.00, 100 ';
$ B = '38 ';
$ C = '85 ';
Echo preg_replace_callback ("/(^
------ Solution ----------------------
\
------ Solution ----------------------
$ B, 0.00, 0.00,) 100/", function ($ m) use ($ c) {return $ m [1]. $ c ;}, $ );
36, 0.00, 0.00, 100
------ Solution ----------------------
37, 0.00, 0.00, 100
------ Solution ----------------------
38, 0.00, 0.00, 85
------ Solution ----------------------
39, 0.00, 0.00, 100