converting multi-dim arrays to php assoc arrays

Started by John Smithabout 23 years ago2 messagesgeneral
Jump to latest
#1John Smith
john_smith_45678@yahoo.com

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

#2Arjen van der Meijden
acm@tweakers.net
In reply to: John Smith (#1)
Re: converting multi-dim arrays to php assoc arrays

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@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] Namens John Smith
Verzonden: zondag 2 februari 2003 10:37
Aan: pgsql-general@postgresql.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