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 :: session() in lumen 
Php :: get redirect url for laravel socialite with api 
Php :: dispatch job with queue name in laravel 
Php :: php undefined index meaNING 
Php :: how to create 404 page in php website 
Php :: pmxi_gallery_image 
Php :: wordpress autoload composer 
Php :: laravel model 
Php :: php != operator 
Php :: get_adjacent_post wordpress 
Php :: symfony messenger 
Php :: string between two strings 
Php :: aws sdk php 
Php :: laravel convert querybuilder to string 
Php :: wordpress change post format 
Php :: ci4 throw new exception 
Php :: php convert array to json 
Php :: how to send data from html to php 
Php :: explode return empty array 
Php :: mysql escape apostrophe 
Php :: laravel collection collapse 
Php :: laravel wrong timestamp 
Php :: acf looping through post types 
Php :: how to create resource controller in laravel 
Php :: array to comma separated string php 
Php :: middleware command in laravel 
Php :: signup api in laravel 
Php :: acos() php 
Php :: laravel how can I use the same foreign key twice in a single table 
Php :: preg_split 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =