
02.07.2009, 23:42
|
|
Постоянный
Регистрация: 11.11.2006
Сообщений: 834
С нами:
10262314
Репутация:
668
|
|
чтото не пашет =)
PHP код:
<?php
function spl($text, $parts) {
$res = array();
$l = intval(strlen($text)/$parts);
preg_match_all('#(.{'.$l.',}?[,\.\?!])#is', $text, $sp, PREG_OFFSET_CAPTURE);
$last = $sp[1][count($sp[1])-1][1]+strlen($sp[1][count($sp[1])-1][0]);
foreach($sp[1] as $arr) {
$res[] = $arr[0];
}
$res[] = substr($text, $last);
return $res;
}
echo "<PRE>";
$a = '123456789 123456789 123456789
132456789 123465789 132456789 123456789';
print_r(spl($a,2));
?>
Вывод
Код:
Array
(
[0] => 123456789 123456789 123456789
132456789 123465789 132456789 123456789
)
|
|
|