Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get last character of string php

substr("testers", -1); // returns "s"
Comment

get last characters of string in php

<?php
	echo substr('Telangana', -3); // ana
	print "<br/>";
	echo substr('Telangana', -1, 1); // a
	print "<br/>";
	echo substr('Telangana', 0, -1); // Telangan
?>
Comment

get last word from string php

function getLastWord($string)
    {
        $string = explode(' ', $string);
        $last_word = array_pop($string);
        return $last_word;
    }
Comment

get last letter in php

substr("testers", -1); // returns "s"
//Or, for multibyte strings :
mb_substr("multibyte string…", -1); // returns "…"
Comment

Get the Last Character of a String in PHP

phpCopy<?php  
$string = 'This is a string';
$lastChar = substr($string, -1);
echo "The last char of the string is $lastChar.";
?>
Comment

Get the Last Character of a String in PHP

phpCopy<?php  
$string = "This is a string";

$lastChar = $string[-1];
echo "The last char of the string is $lastChar.";
?>
Comment

get last word of string php

$split = explode(" ", $string);

echo $split[count($split)-1];
Comment

Get the Last Character of a String in PHP

phpCopy<?php 
$string = "This is a string";
$lastCharPosition = strlen($string) - 1;  
for ($x = $lastCharPosition; $x < strlen($string); $x++) {
    $newString = $string[$x]; 
} 
echo "The last char of the string is $newString.";
?> 
Comment

Get the Last Character of a String in PHP

phpCopy<?php  
$string = "This is a string";
$lengthOfString = strlen($string);
$lastCharPosition = $lengthOfString-1;
$lastChar = $string[$lastCharPosition];
echo "The last char of the string is $lastChar.";
?>
Comment

get last word of string php

$split = explode(" ", $string);

echo $split[count($split)-1];
Comment

Get the Last Character of a String in PHP

phpCopysubstr($stringName, $startingPosition, $lengthOfSubstring);
Comment

PREVIOUS NEXT
Code Example
Php :: wordpress loop permalink 
Php :: get current datatime laravel 
Php :: Delete Query with Where Condition in Codeigniter 
Php :: php replace return character 
Php :: laravel/ui v3.0.0 requires php ^7.3 - your php version (8.0.2) does not satisfy that requirement. 
Php :: laravel ui auth 
Php :: php loop through start and end date 
Php :: if field is filled out acf 
Php :: how uninstall the laravel 
Php :: php unset session variable 
Php :: write if and else in one line laravel 
Php :: curl follow redirect php 
Php :: php array remove empty values 
Php :: laravel enum migration example 
Php :: php date format minus 1 day 
Php :: if any comma in string in php 
Php :: php remove after character 
Php :: how to remove first element in array php 
Php :: check image is available on server php 
Php :: php set content type pdf 
Php :: laravel publish email template 
Php :: symlink in php 
Php :: unix timestamp in php 
Php :: Add [nom] to fillable property to allow mass assignment 
Php :: session has laravel blade 
Php :: php find keyword in string 
Php :: php console output 
Php :: get option field acf 
Php :: symfony clear cache 
Php :: php set error log file 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =