Categories: Snippets

How can I remove 3 characters at the end of a string in php?

echo substr("abcabcabc", 0, -3);

or

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

 

Share

Recent Posts

Clear the browser cache of CSS or JavaScript Using PHP

Other than caching every hour, or every week, you may cache according to file data.…

6 years ago

Current Site URL – Codeigniter

To get host url of current server simply replace application\config\config.php [crayon-679fd50d7a19e054177336/] with [crayon-679fd50d7a1a1112823975/]  

6 years ago

PHP: fopen error handling

You should first test the existence of a file by file_exists(). [crayon-679fd50d7a257297388329/] or simple solution…

6 years ago

Random String PHP

[crayon-679fd50d7a310403112757/] Output the random string with the call below: [crayon-679fd50d7a313922677739/]  

6 years ago

PHP function to make slug (URL string)

Note: from WordPress Use it like this: [crayon-679fd50d7a3ad538865838/] Code: [crayon-679fd50d7a3af785004923/]  

6 years ago

Include all files with in the folder

[crayon-679fd50d7a45f986369360/]  

6 years ago