php - How to split text in 2 halves? -
i've done so:
if(strlen($block_text) > 2000) { $half = strlen($block_text)/2; $second_half = substr($block_text, $half); $block_text = substr($block_text, 0, $half); }
but problem here $second_half
starts in middle of word , $block_text
ends in middle of word. possible tweak somehow first half ends after dot .
?
if(strlen($block_text) > 2000) { $half = strpos($block_text, ".", strlen($block_text)/2); $second_half = substr($block_text, $half); $block_text = substr($block_text, 0, $half); }
now find first dot after half text.
Comments
Post a Comment