从sql [duplicate]中的表中检索前n个字母

This question already has an answer here:

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 ?

</div>

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;
?>

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'