I just saw a piece of php code. I couldn't find an explanation how the interpretor will evaluate this statement $newstring .= "$count{$current}";.
$string = "111221";
for($i = 0; $i < strlen($string); $i++) {
$current = $string[$i];
$count = 1;
while(isset($string[$i + $count]) && ($string[$i + $count] == $current)) $count++;
$newstring .= "$count{$current}";
$i += $count-1;
}
print $newstring;
Anybody please explain this line "$count{$current}". I imagine the doubles quotes is for typecasting to string. But, $count and $current should be numbers. Then what will be the meaning of the curly braces?
$newstring .= "$count{$current}";
is the same for
$newstring .= $count . $current;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With