Received: from mail.nucleus.com (mail.nucleus.com [207.34.93.23]) by postgresql.org (Postfix) with ESMTP id 22531475A0E for ; Thu, 28 Feb 2002 05:08:11 -0500 (EST) Received: from [192.168.1.100] (unverified [207.34.113.45]) by mail.nucleus.com (Vircom SMTPRS 1.1.219) with ESMTP id ; Thu, 28 Feb 2002 03:08:07 -0700 Subject: Re: selecting a string From: Zak Greant To: arun kv Cc: PGSQL In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/1.0.2 Date: 28 Feb 2002 03:09:00 -0700 Message-Id: <1014890941.13850.512.camel@linux> Mime-Version: 1.0 X-Archive-Number: 200202/59 X-Sequence-Number: 965 On Wed, 2002-02-27 at 23:54, arun kv wrote: > hello, after retriving a string from database using select command how to > display the part of string. for eg. after select command i get "computer > architecture algorithms" as output. if i search for string starting with > ar it will search the table will print whole of "com > ... algorithms" instead of > "architecture" how to print only a part of string like this. > thanx in advance > arun Hi Arun, The string and regular expression functions allow you to do things like this. See the PHP manual http://www.php.net/manual for more details. Functions that are likely to be most useful are explode, split and preg_match. Be warned - the preg functions are challenging for users not familiar with regular expressions. Here is an example: $data = pg_result ($result, 0, 0); $array = explode (' ', $data); // Print the second word in the array echo $array[1]; // Print the first and third words in the array echo $array[0] . " " . $array[1]; Good Luck! -- Zak Greant MySQL AB Advocate PHP Quality Assurance Team