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

php extract last n words of string

<?php

$str = "NAME WITH SPACES FIELD1 FIELD2 FIELD3 FIELD4";

preg_match("/(S+)s(S+)s(S+)s(S+)$/", $str, $matches);

var_dump($matches);

/* array(5) {
  [0] => string(27) "FIELD1 FIELD2 FIELD3 FIELD4"
  [1] => string(6) "FIELD1"
  [2] => string(6) "FIELD2"
  [3] => string(6) "FIELD3"
  [4] => string(6) "FIELD4"
} */
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

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

php extract last n words of string

<?php

$str = "NAME WITH SPACES FIELD1 FIELD2 FIELD3 FIELD4";

preg_match("/(S+)s(S+)s(S+)s(S+)$/", $str, $matches);

var_dump($matches);

/* array(5) {
  [0] => string(27) "FIELD1 FIELD2 FIELD3 FIELD4"
  [1] => string(6) "FIELD1"
  [2] => string(6) "FIELD2"
  [3] => string(6) "FIELD3"
  [4] => string(6) "FIELD4"
} */
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 :: wpdb get column 
Php :: php mysql update all rows in table random values 
Php :: order by pre get posts 
Php :: adjacent post sort order by post title 
Php :: laravel validation if another record is not deleted / not null 
Php :: add data in textarea with php variable 
Php :: laravel list all tbales 
Php :: How can I get current controller in yii2 
Php :: PHP - AJAX and MySQL 
Php :: Laravel save without an event 
Php :: laravel collection sort by date 
Php :: php pagination ellipsis 
Php :: php declare variable 
Php :: using laravel passport with mongodb 
Php :: cideigniter orLike() 
Php :: php obfuscate email 
Php :: php inverse / arc cosine 
Php :: php update sql database from form 
Php :: bulk write mongodb php 
Php :: laravel sync with attributes 
Php :: How to remove from a multidimensional array all duplicate elements including the original 
Php :: guzzle download file 
Php :: PHP exif_read_data() 
Php :: using custom fonts in php 
Php :: php dump to page 
Php :: twig render to variable 
Php :: laravel map the output of the api 
Php :: use external variable in php function 
Php :: how to create route in laravel 
Php :: sage theme 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =