PHP das letzte Zeichen in String entfernen
//Remove the last character using substr
$string = substr($string, 0, -1);
Kasmin Nicko
//Remove the last character using substr
$string = substr($string, 0, -1);
<?php
echo substr('abcdef',0, -1); // abcde
?>
$string = rtrim($string, ',');
$arrStr = 'Str1, Str2, str3, ';
echo rtrim($arrStr, ", "); //Str1, Str2, str3
echo substr_replace($arrStr, "", -2); //Str1, Str2, str3
echo substr($arrStr, 0, -2); // Str1, Str2, str3
phpCopy<?php
$mystring = "This is a PHP program.";
echo substr($mystring, 0, -1);
?>
$newarraynama = rtrim($arraynama, ", ");