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

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -