$arr_str = array('qqqqqqqqqqqqqqqqqq 1', 'qwerty qwerty qwerty qwerty  no');
foreach($arr_str as $index_str=>$str){
   $split = str_split($str);
   $abc_repeat = array();
   foreach($split as $index_abc => $abc){
        if(!trim($abc) ){
            continue;
        }
        if(isset($abc_repeat[$abc])){
            if(!isset($abc_repeat[$abc][1])){
                $abc_repeat[$abc][1] = mt_rand(1, 9);
                $arr_str[$index_str][$abc_repeat[$abc][0]] =  $abc_repeat[$abc][1];
            }
            
           
            $arr_str[$index_str][$index_abc] = $abc_repeat[$abc][1];
          continue;
        }
       $abc_repeat[$abc] = array($index_abc) ;
    
   }
}
print_r($arr_str);