简体   繁体   中英

Trying to display text from mysql field starting 30 words into paragraph?

I can't figure this out for the life of me... Using wordpress trying to display excerpt from posts starting 30 words in.. php mysql

Please help!

$str = implode(' ', array_slice(explode(' ', $original), 30));

Convert to array using a space as a seperator. Select starting at array index 30. Convert back to string.

This isn't the best solution, but it is a start. Get your post into a variable ( $str in this case ), and then just remove the first 30 words:

$str = preg_replace( "/(([^ ]* ){30})/", '', $str );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM