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.…

7 years ago

Current Site URL – Codeigniter

To get host url of current server simply replace application\config\config.php [crayon-692a5a2b2e194793769475/] with [crayon-692a5a2b2e197560370722/]  

7 years ago

PHP: fopen error handling

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

7 years ago

Random String PHP

[crayon-692a5a2b2e2c0519701455/] Output the random string with the call below: [crayon-692a5a2b2e2c3646432029/]  

7 years ago

PHP function to make slug (URL string)

Note: from WordPress Use it like this: [crayon-692a5a2b2e35c099278520/] Code: [crayon-692a5a2b2e360662384200/]  

7 years ago

Include all files with in the folder

[crayon-692a5a2b2e40f554706639/]  

7 years ago