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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -