php limit string length
snippet in php

how to check php string length

user9925

<?php
$name = 'abcdef';
echo strlen($str); // 6

$string = ' ab cd ';
echo strlen($str); // 7
?>

php get first 5 characters of string

user4516

$result = substr("Hello How are you", 0, 5); //first 5 chars "Hello"

php limit string length

user8496

if (strlen($str) > 10)
   $str = substr($str, 0, 7) . '...';