Simply count the spaces and add them to the desired length of the capture:
function spaceless_substr($string, $start, $count) {
return substr($string, $start, ($count+substr_count($string, ' ', $start, $count)));
}
$string ="vikas tyagi asd sd as asd";
echo substr($string, 0, 14);
// return: "vikas tyagi a"
echo spaceless_substr($string, 0, 14);
// return: "vikas tyagi asd"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…