php - Split a paragraph into 100 characters arrays -
i'm trying split paragraph 100 characters arrays. algorithm doesn't work...
in output first 1 100 characters. second 1 200, next 1 300 think...
$desc = $this->getdescription(); $desc = preg_replace('/[^a-za-z0-9\s]/', ' ', strip_tags(html_entity_decode($desc))); $desc = preg_replace('/(\s\s+|\t|\n)/', ' ', $desc); $count = strlen($desc); $time = ($count/100); $x = 0; $y = 100; for($i = 0; $i<ceil($time);$i++){ $array[$i] = substr($desc,$x,$y); $array[$i] = str_replace(" ", "+", $array[$i]); $link[$i] = 'http://translate.google.com/translate_tts?tl=en&q=' . $array[$i]; $x+= 100; $y+= 100; }
does know problem?
the output get:
where tried debug it...
characters: 100 | x: 0 | y: 100 | |characters: 200 | x: 100 | y: 200 | |characters: 300 | x: 200 | y: 300 | |characters: 400 | x: 300 | y: 400 | |characters: 422 | x: 400 | y: 500 | |characters: 322 | x: 500 | y: 600 | |characters: 222 | x: 600 | y: 700 | |characters: 122 | x: 700 | y: 800 | |characters: 22 | x: 800 | y: 900
$y length, , increasing 100 on every step of loop.
i recommend comment or delete line :
$y+= 100;
Comments
Post a Comment