Re: Help...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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.



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux