fork download
  1. <?php
  2. $str = 'ремонт котлов';
  3. $words = explode(' ',$str);
  4. $output = [];
  5. foreach($words as $word) {
  6. $output[$word] = preg_split('//u', $word, -1, PREG_SPLIT_NO_EMPTY);
  7. }
  8. print_r($output);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [ремонт] => Array
        (
            [0] => р
            [1] => е
            [2] => м
            [3] => о
            [4] => н
            [5] => т
        )

    [котлов] => Array
        (
            [0] => к
            [1] => о
            [2] => т
            [3] => л
            [4] => о
            [5] => в
        )

)