From: Zak Greant <zak@mysql.com>
To: arun kv <arun@library.iisc.ernet.in>
Cc: PGSQL <pgsql-php@postgresql.org>
Subject: Re: selecting a string
Date: 28 Feb 2002 03:09:00 -0700
Message-ID: <1014890941.13850.512.camel@linux> (raw)
In-Reply-To: <Pine.BSO.4.21.0202281222030.23506-100000@library.iisc.ernet.in>
References: <Pine.BSO.4.21.0202281222030.23506-100000@library.iisc.ernet.in>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: zak@mysql.com, arun@library.iisc.ernet.in
Subject: Re: selecting a string
In-Reply-To: <1014890941.13850.512.camel@linux>
References: <Pine.BSO.4.21.0202281222030.23506-100000@library.iisc.ernet.in> <1014890941.13850.512.camel@linux>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox