You are here: Re: convert XML feed array to assocative « PHP Programming Language « IT news, forums, messages
Re: convert XML feed array to assocative

Posted by petersprc on 01/27/07 04:12

You could certain index the list by sub_family_id:

foreach ($arr as $el) {
$families[substr($el['sub_family_id'], 0, -2)] = $el;
}

On Jan 26, 7:56 pm, "Bosconian" <nob...@nowhere.com> wrote:
> I receive the following array via an XML feed:
>
> Array
> (
> [0] => Array
> (
> [sub_family_id] => 290**
> [image_types] => 1 2**
> [short_name] => Vibratory Soil**
> [long_name] => Vibratory Soil Compactors**
> [image_id] => C018741**
> )
>
> [1] => Array
> (
> [sub_family_id] => 287**
> [image_types] => 1 2**
> [short_name] => Soil**
> [long_name] => Soil Compactors**
> [image_id] => C018741**
> )
>
> [2] => Array
> (
> [sub_family_id] => 286**
> [image_types] => 1 2**
> [short_name] => Landfill**
> [long_name] => Landfill Compactors**
> [image_id] => C018741**
> )
>
> [3] => Array
> (
> [sub_family_id] => 288**
> [image_types] => 1 2**
> [short_name] => Vibratory Asphalt**
> [long_name] => Vibratory Asphalt Compactors**
> [image_id] => C018741**
> )
>
> [4] => Array
> (
> [sub_family_id] => 289**
> [image_types] => 1 2**
> [short_name] => Pneumatic**
> [long_name] => Pneumatic Compactors**
> [image_id] => C018741**
> )
>
> )
>
> What's the best way to make this information easily accessible? My idea is
> to convert it to an associative array (trimming the double asterisks in the
> process) and use the sub_family_id as the key. I could then simply access
> the short_name value "Pneumatic" for sub_family_id "289" like
>
> $array['289']['short_name']
>
> Is this a reasonable approach? Is there a better method?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация