[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] [OT] PHP Question
- Subject: [ale] [OT] PHP Question
- From: jchum at aismedia.com (Jonathan Chum)
- Date: Tue Feb 17 15:26:21 2004
- In-reply-to: <[email protected]>
Substr() is the function that should do it:
http://us2.php.net/substr
Regards,
Jonathan Chum
Systems Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A I S M e d i a , I n c . - "We Build eBusinesses"
115 Perimeter Center Terrace, Suite 540
Atlanta, GA 30346
Tel: 770.350.7998 ext. 502 / Fax: 770.350.9409
http://www.aismedia.com / jchum at aismedia.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----Original Message-----
From: ale-bounces at ale.org [mailto:ale-bounces at ale.org]On Behalf Of
Nathan J. Underwood
Sent: Tuesday, February 17, 2004 3:12 PM
To: ale at ale.org
Subject: [ale] [OT] PHP Question
Is there a way to say "Just give me the first n characters of a string"
in PHP? For example, if the string was "johndoe", and I just wanted the
first 3 characters, or "joh"? I think I could do it with some kind of
regex, but I can't seem to come up with one that works. It will be used
in a MySQL query when it's done, like the following:
$string = "johndoe";
$newstring = justgivemetheleft3($string);
$query = "SELECT * from table where name like "$newstring%"
I can't say give me everything that matches johndoe, because some of
them are john doe, some are john_doe, some are john, etc. But, the
first 3 will always be right.
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale