doubutao6216 2017-09-23 06:05
浏览 50

在PHP中将文本输出限制为50个字符[重复]

This question already has an answer here:

I'm trying to limit my text export in PHP to only 50 characters only

How could I modify the following statement to allow this?

$list[$key]['goods_attr'] = $rows['goods_attr'];
</div>
  • 写回答

2条回答 默认 最新

  • dqnf28092 2017-09-23 06:11
    关注

    You should do this in your SQL query if possible.

    SELECT LEFT(subject , 50) FROM table 
    

    Or you could do it by using substr like this:

    $list[$key]['goods_attr'] = substr($rows['goods_attr'], 0, 50);
    
    评论

报告相同问题?