pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Francisco Mosse - (Zivals) <fmosse@zivals.com>
Cc: pgsql-php@postgresql.org
Subject: Re: Help...
Date: Mon, 16 Dec 2002 16:02:42 -0700 (MST)
Message-ID: <Pine.LNX.4.33.0212161554000.24032-100000@css120.ihs.com> (raw)
In-Reply-To: <001101c2a552$34de9960$c334010a@zivals>

On Mon, 16 Dec 2002, Francisco Mosse - (Zivals) wrote:

> Hi!
> 
> What is wrong? My server has PHP and Postgre
> I can“t understand hoy do I get this error... look
> I start with a value ($quebuscototal) and I should get an array like 
> this ("'abc', 'def', 'ghi', 'jkl') ?
> but with this code, what I receive is an array where the first element 
> is 'abc', 'def', 'ghi', 'jkl' instead of being 'abc' (and the second 
> one, 'def', the third one 'ghi', etc.)
> 
> $quebuscototal = "abc def ghi jkl";
> $quebuscototal = str_replace(' ',' \', \'',$quebuscototal);
> $quebuscototal = "'$quebuscototal'";
> $quebuscofinal = array($quebuscototal);
> $quees = "$quebuscofinal[1] ";

The array() construct is not a function, so it's generally used 
only to create arrays without variables.  I'm not sure if it can handle 
vars inside it.  There are maybe some tricks to get around this, but 
implode/explode are better for mucking with arrays anyway.

I'll try to give a little help.

$quebuscototal = "abc def ghi jkl";
$quees = explode(" ",$quebuscototal);

should result in an array like this:

$quees[0]="abc";
$quees[1]="def";
$quees[2]="ghi";
$quees[3]="jkl";

There are lots of fun ways to manipulate arrays in PHP, by the way.  Look 
at explode, implode, array_pop, array_push and some of the others listed 
in the docs.




view thread (16+ messages)  latest in thread

Message-ID: <Pine.LNX.4.33.0212161554000.24032-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0212161554000.24032-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0212161554000.24032-100000@css120.ihs.com

 · 

reply

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: scott.marlowe@ihs.com, fmosse@zivals.com
  Subject: Re: Help...
  In-Reply-To: <Pine.LNX.4.33.0212161554000.24032-100000@css120.ihs.com>
  References: <001101c2a552$34de9960$c334010a@zivals> <Pine.LNX.4.33.0212161554000.24032-100000@css120.ihs.com>

* 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