turbocueca Posted May 6, 2006 Share Posted May 6, 2006 How to limit a field's char length using PHP without changing anything to the db atributes? Link to comment https://forums.phpfreaks.com/topic/9189-limit-field-length/ Share on other sites More sharing options...
AndyB Posted May 6, 2006 Share Posted May 6, 2006 When displaying data drawn from the database? When preparing data to add to the database? Please clarify what you want to do. Link to comment https://forums.phpfreaks.com/topic/9189-limit-field-length/#findComment-33851 Share on other sites More sharing options...
turbocueca Posted May 6, 2006 Author Share Posted May 6, 2006 I get a result from a database , for example "hello", and i put it in a variable, how can I limit the number of chars to 3? changing the variable value automatically to "hel" ? Link to comment https://forums.phpfreaks.com/topic/9189-limit-field-length/#findComment-33904 Share on other sites More sharing options...
AndyB Posted May 6, 2006 Share Posted May 6, 2006 You can use [a href=\"http://ca.php.net/manual/en/function.substr.php\" target=\"_blank\"]the substr() function[/a], or simply select the leftmost n characters of the database field in your query. Link to comment https://forums.phpfreaks.com/topic/9189-limit-field-length/#findComment-33906 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.