Tuesday, 11 July 2017

Get specified character or word from a string

The substr() function returns a part of a string.

Syntax: substr(string,start,length) where string and start is required. Length is a optional. This tutorial would help about a lot of string issue.

Example :


<?php  
   echo substr("Life is a beautiful", 9);       //beautiful  
   echo substr("Life is a beautiful", 3);       //e is a beautiful  
   echo substr("Life is a beautiful", -14, 2);       //is  
 ?>  

No comments:

Post a Comment

How to create an visitor counter in PHP | hit counter

Total page view in the php. This count hit in the page. <?php session_start(); if(isset($_SESSION['page_view'])){...