cut text after (x) amount of characters

后端 未结 5 1612
谎友^
谎友^ 2021-01-13 07:03

This is in wordpress (not sure that makes a difference)

This bit of php outputs the post title


         


        
5条回答
  •  渐次进展
    2021-01-13 07:37

    if(count($data['nameofpost']) > 20)
    {
        echo(substr($data['nameofpost'], 0, 17)."...");
    }
    

    For $data['nameofpost'] greater then 20 chars it will output the first 17 plus three dots ....

提交回复
热议问题