Answers for "replace first and last letter in string php"

PHP
3

php remove first and last char

<?php

$string = "hello world";

// create a substring starting 1 character from
// the beginning and ending 1 character from the end
$trimmed = substr($string, 1, -1);

echo $trimmed; // prints "ello worl"
Posted by: Guest on May-30-2021
0

php replace first occurrence in string

$pos = strpos($haystack, $needle);
if ($pos !== false) {
    $newstring = substr_replace($haystack, $replace, $pos, strlen($needle));
}
Posted by: Guest on October-04-2021

Code answers related to "replace first and last letter in string php"

Browse Popular Code Answers by Language