Search code examples
phpstringwords

remaining words of string in php


I have a piece of code that shows the first 20 words on my webpage.

$arrtext = explode( ' ', stripslashes( str_replace('\n',chr(10),str_replace('\r',chr(13),$row['text']))), $config['length_story'] + 1);

$arrtext[ $config['length_story'] ] = '';

$row['headtext'] = trim(implode( ' ', $arrtext)) . '...';

This works fine but I want to display the remaing text too without repeating the first 20 words how can I do this?


Solution

  • without rewriting anything, just save the content of

    $arrtext[ $config['length_story'] ] = '';
    

    before overwriting it. it already contains the remaining text

    $remaining = $arrtext[ $config['length_story'] ];
    $arrtext[ $config['length_story'] ] = '';