Search
 
SCRIPT & CODE EXAMPLE
 

PHP

substr() php


<?php
echo substr('abcdef', 1);     // bcdef
echo substr('abcdef', 1, 3);  // bcd
echo substr('abcdef', 0, 4);  // abcd
echo substr('abcdef', 0, 8);  // abcdef
echo substr('abcdef', -1, 1); // f

// Accessing single characters in a string
// can also be achieved using "square brackets"
$string = 'abcdef';
echo $string[0];                 // a
echo $string[3];                 // d
echo $string[strlen($string)-1]; // f

?>

//substr() function returns certain bits of a string 
Comment

php substr

<?php
$rest = substr("abcdef", 0, -1);  // "abcde"
$rest = substr("abcdef", 2, -1);  // "cde"
$rest = substr("abcdef", 4, -4);  // false
$rest = substr("abcdef", -3, -1); // "de"
Comment

substr php

<?php
// Return "world" from the string:
echo substr("Hello world", 6);
?>
Comment

php substr

<?php
$rest = substr("abcdef", -1);    // returns "f"
$rest = substr("abcdef", -2);    // returns "ef"
$rest = substr("abcdef", -3, 1); // returns "d"
?>
Comment

PREVIOUS NEXT
Code Example
Php :: Find ip address location php 
Php :: php preg_match special characters 
Php :: pause php 
Php :: redirect back in codeigniter 
Php :: laravel model insert 
Php :: php set header content type html 
Php :: laravel change column type 
Php :: laravel get env variable 
Php :: php datetime add one hour 
Php :: php array_map with anonymous function 
Php :: php array has value 
Php :: get page name wp 
Php :: how to print query in laravel 
Php :: laravel middleware route group 
Php :: php alert 
Php :: php loop through string 
Php :: js check if div is empty 
Php :: calculate time difference php 
Php :: laravel fillable 
Php :: collection pluck remove duplicates 
Php :: laravel add (s) at the end of text based on how many data 
Php :: wordpress convert non negative 
Php :: check image exist or not in laravel 
Php :: php shorthand if isset 
Php :: php transform associative array to array 
Php :: collection laravel Gets the last key of an array 
Php :: laravel tinker factory 
Php :: laravel blade auth check 
Php :: webuzo set upload limit 
Php :: is_array php 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =