Reply to Re: Determining array type

Your name:

Reply:


Posted by Zini10 on 04/16/05 11:57

i dont think there is a pre-made function but u can use :
(! --untested at all --! )

function determine_array($a)
{
$numric=0;
$assoc=0;

foreach($a as $index=>$value)
{
if(is_numeric($index)){ $numric=1; }
else{ $assoc=1; }
}

return $numric+$assoc*2;
}


then results should be:
empty: 0
numric: 1
assoc : 2
num+assoc : 3

"Nsk" <nsk@wikinerds.org> wrote in message
news:200504160648.55537.nsk@wikinerds.org...
> We have two kinds of arrays in PHP:
>
> $array["name"] = "George"
>
> $array[0] = "George"
>
> How can I determine (with a function returning true/false for example)
> which
> type of array I am working with?
>
> --
> NSK (Nikolaos S. Karastathis)
> Personal Homepage at http://nsk.wikinerds.org/
> Owner of http://portal.wikinerds.org
> Owner of http://www.nerdypc.org

[Back to original 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

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