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? Quote Link to comment 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. Quote Link to comment 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" ? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.