|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-09-09 13:35 UTC] tularis@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 26 09:00:01 2025 UTC |
Description: ------------ Hi, This is my code: <?php $chemString = "H2O,3PO4.12WO3.XH2O,6H4(CH3)2,5H10O5"; $chemString = trim($chemString); $offset = 0; $tempStr = ""; for ($k=0;$k<mb_strlen($chemString);$k++){ if ($k>0 && is_numeric(mb_substr($chemString,$k,1))){ if (preg_match("/^[A-Z]+$/",mb_substr($chemString,$k-1,1))){ $tempStr .= substr($chemString,$offset,1); $tempStr .= "<sub>".substr($chemString,$offset+1,1)."</sub>"; $offset = $offset+3; echo "ggg".strlen($offset)."sss<br />"; } } echo "<br />".$k; } ?> This is the source: <br />0ggg1sss<br /><br />1<br />2<br />3<br />4<br />5<br />6ggg1sss<br /><br />7<br />8<br />9<br />10<br />11<br />12ggg1sss<br /><br />13<br />14<br />15<br />16ggg2sss<br /><br />17<br />18<br />19<br />20<br />21ggg2sss<br /><br />22<br />23<br />24<br />25ggg2sss<br /><br />26<br />27<br />28<br />29<br />30<br />31ggg2sss<br /><br />32<br />33<br />34ggg2sss<br /><br />35 Expected result: ---------------- There is an extra <br /> tag. I know it's hard to see, but looks like a bug. i.e "<br />0ggg1sss<br /><br />1<br />" --- the <br /> in the middle came from nowhere!!