PHP substr

PHP substr is a function that produces a new string from string. It means to say that if you have a string, then you can break it with PHP substr function. We have some PHP substr examples which after seeing you will find out how PHP substring works.

PHP Substr Example

/ ***** Removed First 6 Characters  ***** /

<?php
   echo substr("We are using php substring function",6);
?>

Output:- using php substring function


/ ***** Picked the first 10 characters ***** /

<?php
   echo substr("We are using php substring function",0, 10);
?>

Output:- We are usi


/ ***** Picked 15 characters in between ***** /

<?php
   echo substr("We are using php substring function",6, 21);
?>

Output:- using php substring


/ ***** Picked 22 characters from behind ***** /

<?php
   echo substr("We are using php substring function", -22);
?>

Output:- php substring function


/ ***** Removed 6 characters from front and 22 from behind ***** /

<?php
   echo substr("We are using php substring function", 6, -22);
?>

Output:- using

Browser Support

  • Edge
  • Firefox
  • Internet Explorer
  • Opera
  • Safari
  • Chrome

Frequently Asked Questions

We have answers to some questions that people search on the Internet every day. Let’s know what those questions are and what their answers are.

How do I link CSS to HTML?
To link CSS with html, you can place your file inside the head tag. For example link rel = “stylesheet” href = “mystyle.css”

How do you put a full background image on HTML?
If you want to apply the full background image, then you can apply the image above your body tag. for example Background-image: url (“myimage.jpg”).

What is div in HTML?
In simple language, div is a box inside which you set your elements.

How do you underline in HTML?
With the u tag you can underline your text.

Where do I put CSS in HTML?
There are 3 ways to apply CSS, either you can link your file inside the head tag, or you can add inline CSS, or you can place your CSS on the same page with the style tag.

What is text formatting in HTML?
To make the text appear well, the text is formatted with a few HTML tags.

What is BR tag?
br tag is used to break the line.

What is the HTML code for bold?
You can use b tag and strong tag to bold your text.

What does </ B mean in HTML?
b tag means “bold”.

Note: All the examples you have seen inside this article have all been made by us and tested thoroughly. So you can use all these without any difficulty.