Jump to content

Archived

This topic is now archived and is closed to further replies.

turbocueca

Limit field length

Recommended Posts

How to limit a field's char length using PHP without changing anything to the db atributes?

Share this post


Link to post
Share on other sites
When displaying data drawn from the database? When preparing data to add to the database? Please clarify what you want to do.

Share this post


Link to post
Share on other sites
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" ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.