It's hasn't got much to do with PHP code. The SQL query will do most of the work for you.
Use LIMIT to determine the number of records.
Use SUBSTRING or SUBSTRING_INDEX to trim your content.
PHP Code:
select *, if(length(content)>100,concat((reverse(substring(reverse(substring(content,1,100)),instr(reverse(substring(content,1,100)),' '),length(content)))),'...'),content) as snippet from article