remove first and last character from string php code example

Example 1: remove last letter php

<?php
echo substr('abcdef',0, -1);     // abcde
?>

Example 2: php remove last character from string

$hell = substr('hello', 0, -1);

Example 3: php remove last char from string

//Remove the last character using substr
$string = substr($string, 0, -1);

Example 4: php remove last 3 letters from string

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

Example 5: php string remove last character

echo substr('a,b,c,d,e,', 0, -1);
# => 'a,b,c,d,e'

Tags:

Php Example