03-Apr-2023
.
Admin
Hi Dev,
This tutorial is focused on php get first 10 Characters from string example. I would like to share with you how to use function to get first ten Characters from string in php?. I would like to share with you string to get first ten Characters in php example. We will look at example of get first ten Characters from string in php example.
There are tow example to get First 10 Characters from strings in PHP. in this example, we will use to substr() and mb_substr() function to get First 10 Characters. so Let's both the following example with output.
Example 1: Get First 10 Characters from String
index.php
<?php
$str = "Hello Developers";
//Get first Ten characters from a string
$result = substr($str,0,10);
echo $result;
?>
Output:
Hello Deve
Example 2: Get First 10 Characters from String
index.php
<?php
$str = "Welcome to Nicesnippets.com";
//Get first Ten characters from a string
$result = mb_substr($str,0,10);
echo $result;
?>
Output:
Welcome to
I hope it could help you...
#PHP