<?php $input = 'line1 line2 line3 line4 line5 line6 line7 line8 line9 line10 line11 line12'; foreach($input as $key => $array){ foreach($array as $k => $v){ $input[$key][$k] = '\text '.($k*6+1).',1,'.$v; } } function array_flatten($array) { return FALSE; } foreach ($array as $key => $value) { } else { $result[$key] = $value; } } return $result; } $array = array_flatten($input); ?>
Standard input is empty
Array
(
[0] => \text 1,1,line1
[1] => \text 7,1,line2
[2] => \text 13,1,line3
[3] => \text 19,1,line4
[4] => \text 25,1,line5
[5] => \text 31,1,line6
[6] => \text 37,1,line7
[7] => \text 43,1,line8
[8] => \text 49,1,line9
[9] => \text 1,1,line10
[10] => \text 7,1,line11
[11] => \text 13,1,line12
)