php substr – The Best PHP 3 Examples

Today, We want to share with you php substr.In this post we will show you php string length, hear for
php indexof
we will give you demo and example for implement.In this post, we will learn about PHP Check If String Contains Substring with an example.

Free Live Chat for Any Issue

php substr

Example : 1

<?php
$marketing1="Welcome to Pakainfo.com";
echo $marketing1;
echo '<br>';
echo substr($marketing1,1);
echo '<br>';
echo substr($marketing1,1,5);
echo '<br>';
echo substr($marketing1,0,10);
echo '<br>';
echo substr($marketing1,-1,1);
echo '<br>';
?>

Example : 2

<?php
$marketing1="Welcome to Pakainfo.com";
echo $marketing1;
echo '<br>';
echo substr($marketing1,0,-1);
echo '<br>';
echo substr($marketing1,3,-3);
echo '<br>';
echo substr($marketing1,4,-4);
echo '<br>';
echo substr($marketing1,-3,-2);
echo '<br>';
?>

Example : 3

<?php
$marketing1="Welcome to Pakainfo.com";
echo $marketing1;
echo '<br>';
echo substr($marketing1,-1);
echo '<br>';
echo substr($marketing1,-4);
echo '<br>';
echo substr($marketing1,-5,1);
?>

Use the PHP substr() function

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Example of Extracting Substring from a String in PHP</title>
</head>
<body>

<?php
$market = "Welcome Pakainfo!";

echo substr($market, 0, 5);
echo "<br>";

echo substr($market, 0, -7);
echo "<br>";

echo substr($market, 0);
echo "<br>";

echo substr($market, -6, 5);
echo "<br>";

echo substr($market, -6);
echo "<br>";

echo substr($market, -12);
?>

</body>
</html>

I hope you get an idea about php substr.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.