pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedselecting a string
2+ messages / 2 participants
[nested] [flat]
* selecting a string
@ 2002-02-28 06:54 arun kv <arun@library.iisc.ernet.in>
2002-02-28 10:09 ` Re: selecting a string Zak Greant <zak@mysql.com>
0 siblings, 1 reply; 2+ messages in thread
From: arun kv @ 2002-02-28 06:54 UTC (permalink / raw)
To: pgsql-php
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: selecting a string
2002-02-28 06:54 selecting a string arun kv <arun@library.iisc.ernet.in>
@ 2002-02-28 10:09 ` Zak Greant <zak@mysql.com>
0 siblings, 0 replies; 2+ messages in thread
From: Zak Greant @ 2002-02-28 10:09 UTC (permalink / raw)
To: arun kv <arun@library.iisc.ernet.in>; +Cc: pgsql-php
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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-02-28 10:09 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-28 06:54 selecting a string arun kv <arun@library.iisc.ernet.in>
2002-02-28 10:09 ` Zak Greant <zak@mysql.com>
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