Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get last character of string php

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

get last 3 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

PHP strrchr — Find the last occurrence of a character in a string

<?php
// get last directory in $PATH
$dir = substr(strrchr($PATH, ":"), 1);

// get everything after last newline
$text = "Line 1
Line 2
Line 3";
$last = substr(strrchr($text, 10), 1 );
?>
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 :: laravel get list of columns in a table 
Php :: php number precision 
Php :: php remove everything after character 
Php :: insert php mysql 
Php :: wordpress get particular page content programmatically 
Php :: laravel getbindings 
Php :: date_default_timezone_set for india in php 
Php :: php get method name 
Php :: php copy image from one folder to another 
Php :: if is cart page woocommerce 
Php :: php server name 
Php :: sql row count php pdo 
Php :: Get the number of days between two dates in PHP 
Php :: click confirm before submit form php 
Php :: db symfony 
Php :: php create file html 
Php :: php add string inside string at position 
Php :: wordpress add class on navigation menu 
Php :: logout in laravel 8 
Php :: wordpress order by 
Php :: Add Laravel .env variable to Vue component 
Php :: how to limit excerpt length in wordpress 
Php :: php sleep half a second 
Php :: how to setup cronjob on cakephp on share hosting 
Php :: how to debug php 
Php :: Print exact sql statement executed 
Php :: laravel please provide a valid cache path 
Php :: how to add shortcode in html 
Php :: how to fetch particular css file in wordpress 
Php :: php in array key 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =