@NogDogNov 17.2021 — #Just because I had a few minutes while waiting for a DB query to complete...I came up with this as an idea. :) [code=php] function first($text, $words) { $text = strip_tags($text); $split = preg_split('/s+/', $text); $words = array_slice($split, 0, (int) $words); return implode(' ', $words); } $test = "<h1>Hello, World!</h1>n<p>This is a test. It is <em>only</em> a test.</p>n<p>The end.</p>"; echo first($test, 10);
// OUTPUT: // Hello, World! This is a test. It is only a [/code]