You can also use the recall function until it has only one digit ...
$count = 0;
persistence(2,$count);
function persistence($i,&$c){
$v = str_split($i);
if(count($v) > 1){
$total = array_product($v);
$c++;
persistence($total,$c);
}
}
var_dump($count);
source
share