Limit input length of text that contains HTML tags

后端 未结 2 867
失恋的感觉
失恋的感觉 2020-12-21 13:49

I have a php web sites in wich I can manages articles. On the Add a new article form, there is a rich-text-box (allows HTML input) that I\'d like to limit the character inpu

2条回答
  •  眼角桃花
    2020-12-21 14:27

    html_entity_decode only decodes HTML entities, it doesn't ignore HTML tags. Try:

    strlen(strip_tags(html_entity_decode($string)));
    

    Or the multi-byte equivalent:

    mb_strlen(strip_tags(html_entity_decode($string)), 'auto');
    

提交回复
热议问题