“$ count {$ current}”如何在php中解释这段代码?

时间:2015-06-28 20:04:30

标签: php

我刚看到一段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应该是数字。那么花括号的含义是什么?

1 个答案:

答案 0 :(得分:3)

$newstring .= "$count{$current}";

相同
$newstring .= $count . $current;