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: 
PHP has an `array_map()` which can help you to do this.

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

function countArray($arr) {
    return array_map("countString", $arr);
}

$result = array_map("countArray", $mainArray);

```

Well honestly I do think using two loops would be much easier and clearer...
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);
 }

```