我刚看到一段php代码。我无法找到解释器如何评估此陈述$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;
任何人都请解释这一行"$count{$current}"
。我想双打引号是用于类型转换为字符串。但是,$count
和$current
应该是数字。那么花括号的含义是什么?
答案 0 :(得分:3)
$newstring .= "$count{$current}";
与
相同$newstring .= $count . $current;