Re: converting multi-dim arrays to php assoc arrays

From: Arjen van der Meijden <acm(at)tweakers(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: converting multi-dim arrays to php assoc arrays
Date: 2003-02-02 13:33:38
Message-ID: 003c01c2cabf$b4a5bc40$3ac15e91@acm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

What about something like:
// strip off the first {{ and last }}
$array = explode('},{', $pg_array);
$php_array = array();
foreach($array as $elements)
{
$temp_array = explode(',', $elements);
$php_array[$temp_array[0]] = $temp_array[1];
}

This is not a very generic solution though.

Regards,

Arjen

Van: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] Namens John Smith
Verzonden: zondag 2 februari 2003 10:37
Aan: pgsql-general(at)postgresql(dot)org
Onderwerp: [GENERAL] converting multi-dim arrays to php assoc arrays

Anybody have a method for converting multi-dimensional PG columns to PHP
associative arrays? ie.
{{1,123},{2,234},{3,345},{4,456}}
becomes
1 => 123, 2 => 234, 3=> 345, 4 => 456

Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2003-02-02 14:40:11 Re: php 4.2 postgresql 7.3 help
Previous Message Arjen van der Meijden 2003-02-02 13:04:17 Re: What is the benefit of schemas?