<?php
function checkWord($toCheck, $solution) {
foreach ($toCheck as $pos => $char) {
if ($char == $solution[$pos]) {
$out[$pos] = "<span class=\"green\">$char</span>";
unset($toCheck[$pos], $solution[$pos]); }
}
foreach ($toCheck as $pos => $char) {
$out[$pos] = "<span class=\"red\">$char</span>";
unset($toCheck[$pos], $solution[$solPos]); }
}
$out += $toCheck;
}
PD9waHAKCmZ1bmN0aW9uIGNoZWNrV29yZCgkdG9DaGVjaywgJHNvbHV0aW9uKSB7CiAgICAkdG9DaGVjayA9IHN0cl9zcGxpdCgkdG9DaGVjaywgMSk7CiAgICAkc29sdXRpb24gPSBzdHJfc3BsaXQoJHNvbHV0aW9uLCAxKTsKICAgICRvdXQgPSBhcnJheSgpOwoKICAgIGZvcmVhY2ggKCR0b0NoZWNrIGFzICRwb3MgPT4gJGNoYXIpIHsKICAgICAgICBpZiAoJGNoYXIgPT0gJHNvbHV0aW9uWyRwb3NdKSB7CiAgICAgICAgICAgICRvdXRbJHBvc10gPSAiPHNwYW4gY2xhc3M9XCJncmVlblwiPiRjaGFyPC9zcGFuPiI7CiAgICAgICAgICAgIHVuc2V0KCR0b0NoZWNrWyRwb3NdLCAkc29sdXRpb25bJHBvc10pOwogICAgICAgIH0KICAgIH0KCiAgICBmb3JlYWNoICgkdG9DaGVjayBhcyAkcG9zID0+ICRjaGFyKSB7CiAgICAgICAgaWYgKGZhbHNlICE9PSAkc29sUG9zID0gYXJyYXlfc2VhcmNoKCRjaGFyLCAkc29sdXRpb24pKSB7CiAgICAgICAgICAgICRvdXRbJHBvc10gPSAiPHNwYW4gY2xhc3M9XCJyZWRcIj4kY2hhcjwvc3Bhbj4iOwogICAgICAgICAgICB1bnNldCgkdG9DaGVja1skcG9zXSwgJHNvbHV0aW9uWyRzb2xQb3NdKTsKICAgICAgICB9CiAgICB9CgogICAgJG91dCArPSAkdG9DaGVjazsKICAgIGtzb3J0KCRvdXQpOwoKICAgIHJldHVybiBpbXBsb2RlKCRvdXQpOwp9Cgp2YXJfZHVtcChjaGVja1dvcmQoJ2FiYWFjJywgJ2FhYmJjJykpOw==