Created
March 8, 2013 20:45
-
-
Save hijarian/5119723 to your computer and use it in GitHub Desktop.
В исходном массиве (размер 30 элементов), заполненный цифрами случайным образом, замените все повторные вхождения цифр на 0, а все оставшиеся элементы массива поместить в отдельный массив. Для контроля результата сделайте распечатку массивов, в том числе исходного.
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
$null_value = 0; | |
$input = array(); | |
for ($i = 0; $i < 25; ++$i) { | |
$input[] = mt_rand(1, 10); | |
} | |
print_r($input); | |
$values_to_null = array_diff_key($input, array_unique($input)); | |
foreach ($values_to_null as $key => $value) { | |
$input[$key] = $null_value; | |
} | |
print_r($input); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment