Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function contarMultiplos($numeros, $divisor){
- $conta = 0;
- array_walk($numeros, function($num) use($diviros, &$conta) {
- if ($num % $divisor == 0) {
- $conta++;
- }
- });
- return $conta;
- }
- $mi_arreglo = array(23, 18, 24, 66, 76, 102);
- echo contarMultiplos($mi_arreglo, 6);
- //Resultado: 4
- echo contarMultiplos($mi_arreglo, 2);
- //Resultado: 5
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement