I saw this post which had my ans: MySQL Select Query - Get only first 10 characters of a value How to do the same using php ?
Asked
Active
Viewed 59 times
2 Answers
0
Use the substr()
function. Read about it here http://php.net/manual/en/function.substr.php
$shortString = substr($longString,$startPoint,$numberOfCharactersToReturn);
eg: substr('abcdefg',0,3);
// returns 'abc'

MaggsWeb
- 3,018
- 1
- 13
- 23
0
This can be done by substr function. Following is the working example with code.
http://sugunan.net/demo/substr.php
<?php
$full_str = "Hello, this is my subject and how are you";
$firstn = substr ( $full_str , 0 ,10 );
echo $firstn;
?>

sugunan
- 4,408
- 6
- 41
- 66