Question: How is the way to count length of string in array:

```
$mainArray = [
    [4],
    [3, 4],
    [2, 30, 43, 65, 53, 634]];

```

Output desired:

```
1
1,1
1,2,2,2,2,3

```

My ideia is change to string use string count function, but have the way to do direct on array?

Answer: 
You can use `array_map()` with builtin functions `implode` and `strlen`:

```
$mainArray = [
[4],
[3, 4],
[2, 30, 43, 65, 53, 634]];
print_r(array_map(function ($v) { 
                    return implode(',', array_map('strlen', $v));
                  },
                  $mainArray));

```

Output:

```
Array
(
    [0] => 1
    [1] => 1,1
    [2] => 1,2,2,2,2,3
)

```
Try this, 

```
$mainArray = [
[4],
[3, 4],
[2, 30, 43, 65, 53, 634]];
foreach($mainArray as $key => $element):
    foreach($element as $ele):
        $eleString =  countString($ele);
        if(count($element)>1) $eleString .= ',';
            echo $eleString;
    endforeach;
    echo '<br/>';
 endforeach;

 function countString($s) {
    return strlen((string)$s);
 }

```