Question:What is the output of the following code?
<?php

$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;
?>
 

A 312211 

B 3312212 

C 11221221 

D 221131 

E 3211122 

+ Answer
+ Report
Total Preview: 1034

Copyright © 2024. Powered by Intellect Software Ltd