Re: Best way to read first 20 characters of a string?
| From: | Majk dot Skoric at eventim dot de | Date: | Wed, 02 Dec 2009 15:17:20 +0000 |
| Subject: | Re: Best way to read first 20 characters of a string? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-300213@lists.php.net to get a copy of this message | ||
Not exaclty a php thingie but well ;)
Sql: Select left(column, 20) as c
from table.
Or you can do it with “select substr(columnname, 0,20)“. See the mysql manual. Dunno which of
the two is faster, but i think “left“ is.
Majk
----- Original Message -----
From: oxygenet32@gmail.com <oxygenet32@gmail.com>
To: php-general@lists.php.net <php-general@lists.php.net>
Sent: Wed Dec 02 16:11:55 2009
Subject: [PHP] Best way to read first 20 characters of a string?
Hi everyone,
I'm pulling data from a mysql database, but need only the first 20
characters of each string for a short description, what is the best
method to just grab the first 20 characters from a string regardless
of whether they are letters or numbers?
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php