Created
December 8, 2010 08:35
-
-
Save wowo/733039 to your computer and use it in GitHub Desktop.
Quick question to check PHP 5.3 knowledge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$guys[] = "Robert, age 24"; | |
$guys[] = "Alice, age 19"; | |
$guys[] = "Jacob, age 29"; | |
array_walk($guys, function (&$guy) { | |
$guy = preg_replace_callback("#^\w{2}\w+#", function($value) { | |
$value = current($value); | |
for ($i = 2; $i < strlen($value); $i++) { | |
$value[$i] = "#"; | |
} | |
return $value; | |
}, $guy); | |
}); | |
while (list(, $value) = each($guys)) { | |
printf("%s\n", $value); | |
} | |
//what will be output of above scrip? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment