You are here: Re: PHP Complex Data Structures « PHP « IT news, forums, messages
Re: PHP Complex Data Structures

Posted by zzapper on 10/20/78 11:16

On Wed, 18 May 2005 09:02:01 -0400, wrote:

>I find PHP arrays easier than Perl's data structures. Probably because
>PHP just has arrays, there really is no differentiation between arrays
>(Perl @) and hashes (Perl %). And PHP references arrays the same way as
>variables ($), which may or may not be confusing. You could probably
>look at PHP arrays as Perl hashes (name/value pairs). The functions are
>just about the same: push, pop, shift, unshift, etc.
>
>If you think of all PHP arrays as Perl hashes, you should grasp things
>pretty quick.
>
>On May 17, 2005, at 4:17 PM, zzapper wrote:
>
>> Hi,
>> I seem to remember that you access/use PHP data in the same/similar
>> way to Perl data and that you
>> can create complex data structures ie
>> arrays of arrays, arrays of records etc.
>>
>> For once Google let me down so can any one point at any doc info.
>>
>>
>--

I am delighted with the PHP data structure I have been able to create

Populating/creating the data structure (array of records)

foreach ($results_products_cnt as $l3key => $count)
{
$cathash[$l3key]['href']=$catalog_href;
$cathash[$l3key]['count']=$count;
$cathash[$l3key]['title']=$title;
}

accessing it

foreach ($cathash as $v2 => $v1)
{
$href=$v1['href'];
$count=$v1['count'];
$catalog_h1=$v1['title'];
$html.="<a href='$href'>$v2</a> ($count)<br>";
}

As you say Brent it's really intuitive.

I've been able to drastically shrink my PHP code

--
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips

 

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

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