<?php
class
Statistics {
private
$meta
=
array
();
private
$result
=
array
(
'string'
=>
array
(),
'number'
=>
array
());
private
$meger
=
array
(
'string'
=>
array
(),
'number'
=>
array
());
function
__construct() {
$this
->meta = func_get_args();
}
public
function
show(){
$this
->count_elems(
$this
->meta);
var_dump(
$this
->result);
}
private
function
count_elems(
$array
) {
foreach
(
$array
as
$value
) {
if
(!
is_array
(
$value
)) {
if
(
is_string
(
$value
)){
if
(!in_array(
$value
,
$this
->meger[
'string'
])) {
$this
->meger[
'string'
][] =
$value
;
$this
->result[
'string'
][
$value
] = 1;
}
elseif
(in_array(
$value
,
$this
->meger[
'string'
])) {
$this
->result[
'string'
][
$value
]++;
}
}
else
{
if
(!in_array(
$value
,
$this
->meger[
'number'
])) {
$this
->meger[
'number'
][] =
$value
;
$this
->result[
'number'
][
$value
] = 1;
}
elseif
(in_array(
$value
,
$this
->meger[
'number'
])) {
$this
->result[
'number'
][
$value
]++;
}
}
}
else
{
$this
->count_elems(
$value
);
}
}
}
}
$arr1
=
array
(
'a'
,
'b'
,
array
(1,2,3,4,
'dd'
,
'fdf'
,
'nid'
,
'innid'
,
'iii'
,
'ieir'
));
$arr2
=
array
(
'd'
,
'de'
,
'ef'
,
'2'
,
'5'
,
'8'
);
$arr3
=
array
(
'a'
,
'ef'
,
'r'
,
'q'
);
$arr4
=
array
(
'b'
,
'de'
,
'q'
,
'z'
);
$arr5
=
array
(
'1'
,
'de'
,
'q'
,
'3r'
);
$arr6
=
array
(1, 1, 2,
'mn'
,
'0y'
);
$arr7
=
array
(1,
'v2d'
,
'mn'
,
'0y'
);
$s
=
new
Statistics(
$arr1
,
$arr2
,
$arr3
,
$arr4
,
$arr5
,
$arr6
,
$arr7
);
$s
->show();
?>