개발! 딱 깔끔하고 센스있게!

php 에서 문자열 끝의 세 글자를 어떻게 삭제합니까? 본문

개발 스크랩 메모/PHP

php 에서 문자열 끝의 세 글자를 어떻게 삭제합니까?

렉사이 2020. 12. 20. 22:36

php 에서 문자열 끝의 세 글자를 어떻게 삭제합니까?"abcabc abcabcab"가 "abcabc"!

대답

하면:

echo substr($string, 0, -3); 

Substr 문서에서 말한 것처럼 strlin을 사용할 필요가 없습니다:

If length is given and is negative, then that many characters will be omitted from the end of string

Comments