Someone can help me to rewrite the following code to Javascript ?
public function replace($text)
{
$array = array(
'1' => '1.png',
'2' => '2.png'
);
reset($array);
while (list($code, $path) = each($array))
$text = str_replace($code, "<img src=\"/img/$path\" />", $text);
return $text;
}
A verbatim solution: