Best way to read first 20 characters of a string?
Best way to read first 20 characters of a string?
am 02.12.2009 16:11:55 von chris_payne
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
Re: Best way to read first 20 characters of a string?
am 02.12.2009 16:15:35 von joao
Have you tried tha substr PHP function?
"Chris Payne" escreveu na mensagem
news:554f315f0912020711m5e0cc2e8qd6a1926a80590013@mail.gmail .com...
> 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
Re: Best way to read first 20 characters of a string?
am 02.12.2009 16:16:47 von Daniel Brown
On Wed, Dec 2, 2009 at 10:11, Chris Payne wrote:
> 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?
$chars = substr($yourInput,0,20);
?>
--
daniel.brown@parasane.net || danbrown@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Looking for hosting or dedicated servers? Ask me how we can fit your budget!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Best way to read first 20 characters of a string?
am 02.12.2009 16:17:20 von Majk.Skoric
Tm90IGV4YWNsdHkgYSBwaHAgdGhpbmdpZSBidXQgd2VsbCA7KQ0KDQpTcWw6 IFNlbGVjdCBsZWZ0
KGNvbHVtbiwgMjApIGFzIGMgDQpmcm9tIHRhYmxlLg0KDQpPciB5b3UgY2Fu IGRvIGl0IHdpdGgg
4oCcc2VsZWN0IHN1YnN0cihjb2x1bW5uYW1lLCAwLDIwKeKAnC4gU2VlIHRo ZSBteXNxbCBtYW51
YWwuIER1bm5vIHdoaWNoIG9mIHRoZSB0d28gaXMgZmFzdGVyLCBidXQgaSB0 aGluayDigJxsZWZ0
4oCcIGlzLg0KDQpNYWprDQoNCi0tLS0tIE9yaWdpbmFsIE1lc3NhZ2UgLS0t LS0NCkZyb206IG94
eWdlbmV0MzJAZ21haWwuY29tIDxveHlnZW5ldDMyQGdtYWlsLmNvbT4NClRv OiBwaHAtZ2VuZXJh
bEBsaXN0cy5waHAubmV0IDxwaHAtZ2VuZXJhbEBsaXN0cy5waHAubmV0Pg0K U2VudDogV2VkIERl
YyAwMiAxNjoxMTo1NSAyMDA5DQpTdWJqZWN0OiBbUEhQXSBCZXN0IHdheSB0 byByZWFkIGZpcnN0
IDIwIGNoYXJhY3RlcnMgb2YgYSBzdHJpbmc/DQoNCkhpIGV2ZXJ5b25lLA0K DQpJJ20gcHVsbGlu
ZyBkYXRhIGZyb20gYSBteXNxbCBkYXRhYmFzZSwgYnV0IG5lZWQgb25seSB0 aGUgZmlyc3QgMjAN
CmNoYXJhY3RlcnMgb2YgZWFjaCBzdHJpbmcgZm9yIGEgc2hvcnQgZGVzY3Jp cHRpb24sIHdoYXQg
aXMgdGhlIGJlc3QNCm1ldGhvZCB0byBqdXN0IGdyYWIgdGhlIGZpcnN0IDIw IGNoYXJhY3RlcnMg
ZnJvbSBhIHN0cmluZyByZWdhcmRsZXNzDQpvZiB3aGV0aGVyIHRoZXkgYXJl IGxldHRlcnMgb3Ig
bnVtYmVycz8NCg0KQ2hyaXMNCg0KLS0gDQpQSFAgR2VuZXJhbCBNYWlsaW5n IExpc3QgKGh0dHA6
Ly93d3cucGhwLm5ldC8pDQpUbyB1bnN1YnNjcmliZSwgdmlzaXQ6IGh0dHA6 Ly93d3cucGhwLm5l
dC91bnN1Yi5waHANCg0K
Re: Best way to read first 20 characters of a string?
am 02.12.2009 16:18:26 von Devendra Jadhav
--001636d34890e335330479c062ad
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
mysql substr function
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html #function_subst=
r
On Wed, Dec 2, 2009 at 8:41 PM, Chris Payne wr=
ote:
> 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
>
>
--=20
Devendra Jadhav
दà¥à¤µà¥à¤à¤¦à¥ र =
à¤à¤¾à¤§à¤µ
--001636d34890e335330479c062ad--
Re: Best way to read first 20 characters of a string?
am 02.12.2009 16:31:54 von chris_payne
Thank you everyone, I REALLY appreciate it. Sorry my head isn't in
place today and I couldn't think.
Chris
On Wed, Dec 2, 2009 at 10:18 AM, Devendra Jadhav wr=
ote:
> mysql substr function
> http://dev.mysql.com/doc/refman/5.0/en/string-functions.html #function_sub=
str
>
> On Wed, Dec 2, 2009 at 8:41 PM, Chris Payne
> wrote:
>>
>> 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
>>
>
>
>
> --
> Devendra Jadhav
> दà¥à¤µà¥à¤à¤¦à¥ र =
à¤à¤¾à¤§à¤µ
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php