if (isset($values) && count($params) == count($values))
{
$counter = 0;
$html = str_replace('mxyzptlk', 'value', $html);
foreach ($values as $value)
{
$string = 'klf' . strval($counter);
$html = str_replace($string, $value, $html);
$counter++;
}
}
This is a fairly simple piece of code. Earlier in the program, I generate a list of values using a loop that results in the following:
klf0 klf1 klf2 klf3 ... klf19 klf20
The loop above is supposed to go through this list of "klf" values and replace them with something else.
The weird thing that is happening is that the entire page works fine, until the loop gets to "klf10" and above. What happens then is that the strings are being truncated, changing "klf10" to "0" and "klf11" to "1" and so on. Something about double digits is screwing this up.
Like I said, the code works fine up to the str_replace function-- outputting $string right before it results in proper values ("klf10") and outputting $value right before the str_replace shows the right value to replace "klf(n)" with.
Any ideas as to why it's doing this? I tried converting the integer parts to strings but it obviously didn't help.
Edit: I have confirmed that the strings aren't actually being truncated, but "klf10" is in fact being partially replaced by the value of "klf1." I'm going to keep playing around with it but thought it might help in diagnosis.